Skip to content

Instantly share code, notes, and snippets.

@nzifnab
Created July 5, 2010 06:09
Show Gist options
  • Save nzifnab/464059 to your computer and use it in GitHub Desktop.
Save nzifnab/464059 to your computer and use it in GitHub Desktop.
Crappy Weather
# Somewhere in heaven...
rainy_regions = Region.find(:all, :conditions => ["name IN (?)", [:denver, :loveland, :fort_collins]])
rainy_regions.each{ |rain_here| rain_here.saturate_clouds! }
# Meanwhile, in the stratosphere...
if (saturated_regions = Cloud.find_all_by_density(MAX_CLOUD_SATURATION_DENSITY).map{|cloud| cloud.region}).any?
current_weather = Rain.new( :regions => saturated_regions )
current_weather.quantity = :downpour
current_weather.duration = 6.hours
current_weather.begin!
events = Event.find(:all, :conditions => ["type = ? AND region IN (?)", "outdoor", saturated_regions])
events.each{ |event| event.cancel! }
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment