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['query']['results']['channel']
  @title            = @doc['item']['title']
  @link             = @doc['link']
  @description      = @doc['description']
  @language         = @doc['language']
  @last_build_date  = Time.parse(@doc['lastBuildDate'])
  @ttl              = @doc['ttl'].to_i
  @lat              = @doc['item']['lat'].to_f
  @long             = @doc['item']['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['astronomy'])
end

#atmosphereObject



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

def atmosphere
  YahooWeather::Atmosphere.new(@doc['atmosphere'])
end

#conditionObject



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

def condition
  YahooWeather::Condition.new(@doc['item']['condition'])
end

#forecastsObject



42
43
44
45
46
47
48
# File 'lib/yahoo_weather/response.rb', line 42

def forecasts
  forecasts = []
  @doc['item']['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['location'])
end

#unitsObject



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

def units
  YahooWeather::Units.new(@doc['units'])
end

#windObject



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

def wind
  YahooWeather::Wind.new(@doc['wind'])
end