Class: YahooWeather::Response
- Inherits:
-
Object
- Object
- YahooWeather::Response
- Defined in:
- lib/yahoo_weather/response.rb
Instance Attribute Summary collapse
-
#description ⇒ Object
readonly
Returns the value of attribute description.
-
#doc ⇒ Object
readonly
Returns the value of attribute doc.
-
#language ⇒ Object
readonly
Returns the value of attribute language.
-
#last_build_date ⇒ Object
readonly
Returns the value of attribute last_build_date.
-
#lat ⇒ Object
readonly
Returns the value of attribute lat.
-
#link ⇒ Object
readonly
Returns the value of attribute link.
-
#long ⇒ Object
readonly
Returns the value of attribute long.
-
#title ⇒ Object
readonly
Returns the value of attribute title.
-
#ttl ⇒ Object
readonly
Returns the value of attribute ttl.
Instance Method Summary collapse
- #astronomy ⇒ Object
- #atmosphere ⇒ Object
- #condition ⇒ Object
- #forecasts ⇒ Object
-
#initialize(doc) ⇒ Response
constructor
A new instance of Response.
- #location ⇒ Object
- #units ⇒ Object
- #wind ⇒ Object
Constructor Details
#initialize(doc) ⇒ Response
Returns a new instance of Response.
6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/yahoo_weather/response.rb', line 6 def initialize(doc) @doc = doc @title = get_text('item/title') @link = get_text('link') @description = get_text('description') @language = get_text('language') @last_build_date = Time.parse(get_text('lastBuildDate')) @ttl = get_text('ttl').to_i @lat = get_text('item/geo|lat').to_f @long = get_text('item/geo|long').to_f end |
Instance Attribute Details
#description ⇒ Object (readonly)
Returns the value of attribute description.
2 3 4 |
# File 'lib/yahoo_weather/response.rb', line 2 def description @description end |
#doc ⇒ Object (readonly)
Returns the value of attribute doc.
2 3 4 |
# File 'lib/yahoo_weather/response.rb', line 2 def doc @doc end |
#language ⇒ Object (readonly)
Returns the value of attribute language.
2 3 4 |
# File 'lib/yahoo_weather/response.rb', line 2 def language @language end |
#last_build_date ⇒ Object (readonly)
Returns the value of attribute last_build_date.
2 3 4 |
# File 'lib/yahoo_weather/response.rb', line 2 def last_build_date @last_build_date end |
#lat ⇒ Object (readonly)
Returns the value of attribute lat.
2 3 4 |
# File 'lib/yahoo_weather/response.rb', line 2 def lat @lat end |
#link ⇒ Object (readonly)
Returns the value of attribute link.
2 3 4 |
# File 'lib/yahoo_weather/response.rb', line 2 def link @link end |
#long ⇒ Object (readonly)
Returns the value of attribute long.
2 3 4 |
# File 'lib/yahoo_weather/response.rb', line 2 def long @long end |
#title ⇒ Object (readonly)
Returns the value of attribute title.
2 3 4 |
# File 'lib/yahoo_weather/response.rb', line 2 def title @title end |
#ttl ⇒ Object (readonly)
Returns the value of attribute ttl.
2 3 4 |
# File 'lib/yahoo_weather/response.rb', line 2 def ttl @ttl end |
Instance Method Details
#astronomy ⇒ Object
26 27 28 |
# File 'lib/yahoo_weather/response.rb', line 26 def astronomy YahooWeather::Astronomy.new(@doc.at('yweather|astronomy')) end |
#atmosphere ⇒ Object
30 31 32 |
# File 'lib/yahoo_weather/response.rb', line 30 def atmosphere YahooWeather::Atmosphere.new(@doc.at('yweather|atmosphere')) end |
#condition ⇒ Object
34 35 36 |
# File 'lib/yahoo_weather/response.rb', line 34 def condition YahooWeather::Condition.new(@doc.at('item/yweather|condition')) end |
#forecasts ⇒ Object
42 43 44 45 46 47 48 |
# File 'lib/yahoo_weather/response.rb', line 42 def forecasts forecasts = [] @doc.search('item/yweather|forecast').each do |forecast| forecasts << YahooWeather::Forecast.new(forecast) end forecasts end |
#location ⇒ Object
18 19 20 |
# File 'lib/yahoo_weather/response.rb', line 18 def location YahooWeather::Location.new(@doc.at('yweather|location')) end |
#units ⇒ Object
22 23 24 |
# File 'lib/yahoo_weather/response.rb', line 22 def units YahooWeather::Units.new(@doc.at('yweather|units')) end |
#wind ⇒ Object
38 39 40 |
# File 'lib/yahoo_weather/response.rb', line 38 def wind YahooWeather::Wind.new(@doc.at('yweather|wind')) end |