class PotOfCoffee::Brewer

Attributes

quantity[R]
strength[R]
units[R]

Public Class Methods

new(quantity: 12, strength: :medium, units: Units::Imperial) click to toggle source
# File lib/pot_of_coffee/brewer.rb, line 7
def initialize(quantity: 12, strength: :medium, units: Units::Imperial)
  fail Errors::NegativeNumber unless quantity.positive?
  fail Errors::WrongStrength unless units.table.keys.include?(strength)

  @quantity = quantity
  @strength = strength
  @units = units
end

Public Instance Methods

grounds() click to toggle source
# File lib/pot_of_coffee/brewer.rb, line 16
def grounds
  (quantity * units.table.fetch(strength)).round(2)
end
instructions() click to toggle source
# File lib/pot_of_coffee/brewer.rb, line 20
    def instructions
      <<~INSTRUCTIONS
        Cups desired: #{quantity}
        Brew strength: #{strength}
        Grounds needed: #{grounds} #{units.abbreviation}
      INSTRUCTIONS
    end