Class: LemonadeStand::Day
- Inherits:
-
Object
- Object
- LemonadeStand::Day
- Defined in:
- lib/lemonade_stand/day.rb
Instance Attribute Summary collapse
-
#number ⇒ Object
Returns the value of attribute number.
Instance Method Summary collapse
- #calculate_glasses_sold(choice) ⇒ Object
- #cost_per_glass ⇒ Object
- #event ⇒ Object
- #sales_for(choice) ⇒ Object
- #weather ⇒ Object
Instance Attribute Details
#number ⇒ Object
Returns the value of attribute number.
5 6 7 |
# File 'lib/lemonade_stand/day.rb', line 5 def number @number end |
Instance Method Details
#calculate_glasses_sold(choice) ⇒ Object
28 29 30 31 |
# 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 ⇒ Object
20 21 22 23 24 25 26 |
# 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 ⇒ Object
33 34 35 |
# File 'lib/lemonade_stand/day.rb', line 33 def event @event ||= Event.for(self) end |
#sales_for(choice) ⇒ Object
11 12 13 14 15 16 17 18 |
# 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 ⇒ Object
7 8 9 |
# File 'lib/lemonade_stand/day.rb', line 7 def weather @weather ||= LemonadeStand::Weather.weather_for self end |