Class: YahooWeather::Response

Inherits:
Object
  • Object
show all
Defined in:
lib/yahoo_weather/response.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#descriptionObject (readonly)

Returns the value of attribute description.



2
3
4
# File 'lib/yahoo_weather/response.rb', line 2

def description
  @description
end

#docObject (readonly)

Returns the value of attribute doc.



2
3
4
# File 'lib/yahoo_weather/response.rb', line 2

def doc
  @doc
end

#languageObject (readonly)

Returns the value of attribute language.



2
3
4
# File 'lib/yahoo_weather/response.rb', line 2

def language
  @language
end

#last_build_dateObject (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

#latObject (readonly)

Returns the value of attribute lat.



2
3
4
# File 'lib/yahoo_weather/response.rb', line 2

def lat
  @lat
end

Returns the value of attribute link.



2
3
4
# File 'lib/yahoo_weather/response.rb', line 2

def link
  @link
end

#longObject (readonly)

Returns the value of attribute long.



2
3
4
# File 'lib/yahoo_weather/response.rb', line 2

def long
  @long
end

#titleObject (readonly)

Returns the value of attribute title.



2
3
4
# File 'lib/yahoo_weather/response.rb', line 2

def title
  @title
end

#ttlObject (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

#astronomyObject



26
27
28
# File 'lib/yahoo_weather/response.rb', line 26

def astronomy
  YahooWeather::Astronomy.new(@doc.at('yweather|astronomy'))
end

#atmosphereObject



30
31
32
# File 'lib/yahoo_weather/response.rb', line 30

def atmosphere
  YahooWeather::Atmosphere.new(@doc.at('yweather|atmosphere'))
end

#conditionObject



34
35
36
# File 'lib/yahoo_weather/response.rb', line 34

def condition
  YahooWeather::Condition.new(@doc.at('item/yweather|condition'))
end

#forecastsObject



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

#locationObject



18
19
20
# File 'lib/yahoo_weather/response.rb', line 18

def location
  YahooWeather::Location.new(@doc.at('yweather|location'))
end

#unitsObject



22
23
24
# File 'lib/yahoo_weather/response.rb', line 22

def units
  YahooWeather::Units.new(@doc.at('yweather|units'))
end

#windObject



38
39
40
# File 'lib/yahoo_weather/response.rb', line 38

def wind
  YahooWeather::Wind.new(@doc.at('yweather|wind'))
end