Class: Weather::Response
- Inherits:
-
Object
- Object
- Weather::Response
- Defined in:
- lib/weather-api/response.rb
Instance Attribute Summary collapse
-
#astronomy ⇒ Object
readonly
a Weather::Astronomy object containing sunrise and sunset information for the requested location.
-
#atmosphere ⇒ Object
readonly
a Weather::Atmosphere object containing the atmosphere information for the requested location.
-
#condition ⇒ Object
readonly
a Weather::Condition object detailing the current conditions of the requested location.
-
#description ⇒ Object
readonly
the HTML summarizing current weather conditions for the requested location.
-
#forecasts ⇒ Object
readonly
a collection of Weather::Forecast objects containing high-level forecasted weather for upcoming days.
-
#image ⇒ Object
readonly
a Weather::Image object containing an image icon representing the current weather for the requested location.
-
#latitude ⇒ Object
readonly
the latitude for the requested location.
-
#location ⇒ Object
readonly
a Weather::Location object containing the geographical names of the requested location.
-
#longitude ⇒ Object
readonly
the longitude for the requested location.
-
#request_location ⇒ Object
readonly
the location string initially requested of the service.
-
#request_url ⇒ Object
readonly
the url with which the Yahoo! Weather service was accessed to build the response.
-
#title ⇒ Object
readonly
the title of the weather information for the requested location.
-
#units ⇒ Object
readonly
a Weather::Units object containig the units corresponding to the information contained in the response.
-
#wind ⇒ Object
readonly
a Weather::Wind object containing the wind information for the requested location.
Instance Method Summary collapse
-
#initialize(request_location, request_url, doc) ⇒ Response
constructor
A new instance of Response.
Constructor Details
#initialize(request_location, request_url, doc) ⇒ Response
Returns a new instance of Response.
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/weather-api/response.rb', line 55 def initialize(request_location, request_url, doc) # save the request params @request_location = request_location @request_url = request_url @astronomy = Astronomy.new doc[:astronomy] @location = Location.new doc[:location] @units = Units.new doc[:units] @wind = Wind.new doc[:wind] @atmosphere = Atmosphere.new doc[:atmosphere] @image = Image.new doc[:item][:description] @forecasts = [] @condition = Condition.new doc[:item][:condition] doc[:item][:forecast].each do |forecast| @forecasts << Forecast.new(forecast) end @latitude = doc[:item][:lat].to_f @longitude = doc[:item][:long].to_f @title = doc[:item][:title].strip @description = doc[:item][:description].strip end |
Instance Attribute Details
#astronomy ⇒ Object (readonly)
a Weather::Astronomy object containing sunrise and sunset information for the requested location
5 6 7 |
# File 'lib/weather-api/response.rb', line 5 def astronomy @astronomy end |
#atmosphere ⇒ Object (readonly)
a Weather::Atmosphere object containing the atmosphere information for the requested location
21 22 23 |
# File 'lib/weather-api/response.rb', line 21 def atmosphere @atmosphere end |
#condition ⇒ Object (readonly)
a Weather::Condition object detailing the current conditions of the requested location
25 26 27 |
# File 'lib/weather-api/response.rb', line 25 def condition @condition end |
#description ⇒ Object (readonly)
the HTML summarizing current weather conditions for the requested location
33 34 35 |
# File 'lib/weather-api/response.rb', line 33 def description @description end |
#forecasts ⇒ Object (readonly)
a collection of Weather::Forecast objects containing high-level forecasted weather for upcoming days
29 30 31 |
# File 'lib/weather-api/response.rb', line 29 def forecasts @forecasts end |
#image ⇒ Object (readonly)
a Weather::Image object containing an image icon representing the current weather for the requested location
37 38 39 |
# File 'lib/weather-api/response.rb', line 37 def image @image end |
#latitude ⇒ Object (readonly)
the latitude for the requested location
40 41 42 |
# File 'lib/weather-api/response.rb', line 40 def latitude @latitude end |
#location ⇒ Object (readonly)
a Weather::Location object containing the geographical names of the requested location
9 10 11 |
# File 'lib/weather-api/response.rb', line 9 def location @location end |
#longitude ⇒ Object (readonly)
the longitude for the requested location
43 44 45 |
# File 'lib/weather-api/response.rb', line 43 def longitude @longitude end |
#request_location ⇒ Object (readonly)
the location string initially requested of the service.
46 47 48 |
# File 'lib/weather-api/response.rb', line 46 def request_location @request_location end |
#request_url ⇒ Object (readonly)
the url with which the Yahoo! Weather service was accessed to build the response
50 51 52 |
# File 'lib/weather-api/response.rb', line 50 def request_url @request_url end |
#title ⇒ Object (readonly)
the title of the weather information for the requested location
53 54 55 |
# File 'lib/weather-api/response.rb', line 53 def title @title end |
#units ⇒ Object (readonly)
a Weather::Units object containig the units corresponding to the information contained in the response
13 14 15 |
# File 'lib/weather-api/response.rb', line 13 def units @units end |
#wind ⇒ Object (readonly)
a Weather::Wind object containing the wind information for the requested location
17 18 19 |
# File 'lib/weather-api/response.rb', line 17 def wind @wind end |