Class: OpenWeatherApi::Forecast
- Inherits:
-
Object
- Object
- OpenWeatherApi::Forecast
- Defined in:
- lib/open_weather_api/forecast.rb
Instance Method Summary collapse
- #[](key) ⇒ Object
-
#initialize(forecast) ⇒ Forecast
constructor
A new instance of Forecast.
- #method_missing(name, *args, &block) ⇒ Object
Constructor Details
#initialize(forecast) ⇒ Forecast
Returns a new instance of Forecast.
3 4 5 |
# File 'lib/open_weather_api/forecast.rb', line 3 def initialize(forecast) @forecast_hash = forecast.parsed_response end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args, &block) ⇒ Object
11 12 13 14 15 16 17 18 19 |
# File 'lib/open_weather_api/forecast.rb', line 11 def method_missing(name, *args, &block) if @forecast_hash.respond_to? name @forecast_hash.send(name) elsif @forecast_hash.has_key?(name.to_s) @forecast_hash[name.to_s] else super end end |
Instance Method Details
#[](key) ⇒ Object
7 8 9 |
# File 'lib/open_weather_api/forecast.rb', line 7 def [](key) @forecast_hash[key] end |