class LemonadeStand::Event
Constants
- DAY_TYPES
Public Class Methods
build(type)
click to toggle source
# File lib/lemonade_stand/event.rb, line 30 def self.build type eval("LemonadeStand::#{type.to_s.split('_').map { |x| x.capitalize }.join('')}Event").new end
cloudy_event_for(_)
click to toggle source
# File lib/lemonade_stand/event.rb, line 19 def self.cloudy_event_for _ if rand(100) < 25 return build(:storm) end return build(:rain) end
for(day)
click to toggle source
# File lib/lemonade_stand/event.rb, line 7 def self.for day type = DAY_TYPES.select { |x| day.weather.send("#{x}?".to_sym) }.first send("#{type}_event_for".to_sym, day) end
hot_and_dry_event_for(_)
click to toggle source
# File lib/lemonade_stand/event.rb, line 26 def self.hot_and_dry_event_for _ build(:heat_wave) end
sunny_event_for(day)
click to toggle source
# File lib/lemonade_stand/event.rb, line 12 def self.sunny_event_for day if day.number > 2 && rand(100) < 25 return build(:street_work) end return build(:normal) end