Created
July 5, 2010 06:09
-
-
Save nzifnab/464059 to your computer and use it in GitHub Desktop.
Crappy Weather
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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