Class: YahooWeather::Weather
- Inherits:
-
Object
- Object
- YahooWeather::Weather
- Defined in:
- lib/yahoo_weather.rb
Instance Method Summary collapse
-
#initialize(woeid, units, day, format, all) ⇒ Weather
constructor
Create new Weather instance.
-
#to_s ⇒ Object
Returns @weather in string format.
Constructor Details
#initialize(woeid, units, day, format, all) ⇒ Weather
Create new Weather instance. All available information is put in @weather hash. woeid:: Local woeid code; units:: Measure unit sets (:metric/:english); day:: Which day to show: [0] Current observation; [1] Today’s forecast; [2-5] Tomorrow’s forecast, and so on. format:: Output format directives; all:: (Boolean): Show all available info or not.
36 37 38 39 40 41 42 43 44 |
# File 'lib/yahoo_weather.rb', line 36 def initialize(woeid, units, day, format, all) _set_members(woeid, units, day, format, all) rss = _get_rss doc = Document.new(rss) general = _initialize_general(doc) condition = _initialize_condition(doc) forecast = _initialize_forecast(doc) @weather = _add_format_keys(general, condition, forecast) end |
Instance Method Details
#to_s ⇒ Object
Returns @weather in string format. This shows current weather information, if no other option has been set. If you specify a @format, no other info will be shown, other than the ones you asked for.
49 50 51 52 53 |
# File 'lib/yahoo_weather.rb', line 49 def to_s return _sprintf(@format) if @format return _sprintf(FORMAT_ALL) if @all return _sprintf(FORMAT[@day]) if @day end |