Class: Forecast
- Inherits:
-
Object
- Object
- Forecast
- Includes:
- Model
- Defined in:
- lib/forecast.rb,
lib/forecast/cache.rb,
lib/forecast/model.rb,
lib/forecast/utils.rb,
lib/forecast/config.rb,
lib/forecast/adapter.rb,
lib/forecast/version.rb,
lib/forecast/collection.rb,
lib/forecast/adapters/yahoo_adapter.rb,
lib/forecast/adapters/wunderground_adapter.rb,
lib/forecast/adapters/open_weather_map_adapter.rb
Defined Under Namespace
Modules: Adapter, Adapters, Model, Utils Classes: Cache, Collection, Config
Constant Summary collapse
- VERSION =
"0.0.3"
Instance Attribute Summary collapse
-
#condition ⇒ Object
Returns the value of attribute condition.
-
#date ⇒ Object
Returns the value of attribute date.
-
#latitude ⇒ Object
Returns the value of attribute latitude.
-
#longitude ⇒ Object
Returns the value of attribute longitude.
-
#orig_condition ⇒ Object
Returns the value of attribute orig_condition.
-
#temp ⇒ Object
Returns the value of attribute temp.
-
#temp_max ⇒ Object
Returns the value of attribute temp_max.
-
#temp_min ⇒ Object
Returns the value of attribute temp_min.
Class Method Summary collapse
- .config ⇒ Object
- .configure {|self.config| ... } ⇒ Object
- .current(latitude, longitude) ⇒ Object
- .daily(latitude, longitude) ⇒ Object
- .hourly(latitude, longitude) ⇒ Object
Methods included from Model
#as_json, #from_json, #icon, included, #initialize, #to_json
Instance Attribute Details
#condition ⇒ Object
Returns the value of attribute condition.
18 19 20 |
# File 'lib/forecast.rb', line 18 def condition @condition end |
#date ⇒ Object
Returns the value of attribute date.
18 19 20 |
# File 'lib/forecast.rb', line 18 def date @date end |
#latitude ⇒ Object
Returns the value of attribute latitude.
18 19 20 |
# File 'lib/forecast.rb', line 18 def latitude @latitude end |
#longitude ⇒ Object
Returns the value of attribute longitude.
18 19 20 |
# File 'lib/forecast.rb', line 18 def longitude @longitude end |
#orig_condition ⇒ Object
Returns the value of attribute orig_condition.
18 19 20 |
# File 'lib/forecast.rb', line 18 def orig_condition @orig_condition end |
#temp ⇒ Object
Returns the value of attribute temp.
18 19 20 |
# File 'lib/forecast.rb', line 18 def temp @temp end |
#temp_max ⇒ Object
Returns the value of attribute temp_max.
18 19 20 |
# File 'lib/forecast.rb', line 18 def temp_max @temp_max end |
#temp_min ⇒ Object
Returns the value of attribute temp_min.
18 19 20 |
# File 'lib/forecast.rb', line 18 def temp_min @temp_min end |
Class Method Details
.config ⇒ Object
61 62 63 |
# File 'lib/forecast/config.rb', line 61 def self.config @@config ||= Config.new end |
.configure {|self.config| ... } ⇒ Object
65 66 67 68 69 70 71 72 |
# File 'lib/forecast/config.rb', line 65 def self.configure yield self.config # puts 'configured' # if self.config.config_file != nil # puts 'load config from file' # self.config.load(@config_file) # end end |
.current(latitude, longitude) ⇒ Object
23 24 25 26 27 28 29 30 31 |
# File 'lib/forecast.rb', line 23 def current(latitude, longitude) cache_key = "current:#{latitude},#{longitude}" forecast = read_cache(cache_key) if forecast == nil forecast = adapter.current(latitude, longitude) write_cache(cache_key, forecast) end return forecast end |
.daily(latitude, longitude) ⇒ Object
43 44 45 46 47 48 49 50 51 |
# File 'lib/forecast.rb', line 43 def daily(latitude, longitude) cache_key = "daily:#{latitude},#{longitude}" forecasts = read_cache(cache_key) if forecasts == nil forecasts = adapter.daily(latitude, longitude) write_cache(cache_key, forecasts) end return forecasts end |
.hourly(latitude, longitude) ⇒ Object
33 34 35 36 37 38 39 40 41 |
# File 'lib/forecast.rb', line 33 def hourly(latitude, longitude) cache_key = "hourly:#{latitude},#{longitude}" forecasts = read_cache(cache_key) if forecasts == nil forecasts = adapter.hourly(latitude, longitude) write_cache(cache_key, forecasts) end return forecasts end |