class LemonadeStand::Day

Attributes

number[RW]

Public Instance Methods

calculate_glasses_sold(choice) click to toggle source
# File lib/lemonade_stand/day.rb, line 28
def calculate_glasses_sold choice
  max_sales = [choice.max_sales, event.modify(choice)].max
  [choice.glasses_made, max_sales].min.round
end
cost_per_glass() click to toggle source
# File lib/lemonade_stand/day.rb, line 20
def cost_per_glass
  case number
  when (1..2) then 2
  when (3..4) then 4
  else 5
  end
end
event() click to toggle source
# File lib/lemonade_stand/day.rb, line 33
def event
  @event ||= Event.for(self)
end
sales_for(choice) click to toggle source
# File lib/lemonade_stand/day.rb, line 11
def sales_for choice
  data = { 
           glasses_sold: calculate_glasses_sold(choice),
           choice:       choice,
           day:          self,
         }
  LemonadeStand::Result.new data
end
weather() click to toggle source
# File lib/lemonade_stand/day.rb, line 7
def weather
  @weather ||= LemonadeStand::Weather.weather_for self
end