Class: Yweather::Client
- Inherits:
-
Object
- Object
- Yweather::Client
- Defined in:
- lib/yweather/client.rb
Constant Summary collapse
- @@BASE_URL =
"http://weather.yahooapis.com/forecastrss"
Instance Attribute Summary collapse
-
#response ⇒ Object
readonly
Returns the value of attribute response.
Instance Method Summary collapse
- #get_feed_for_woeid(woeid, options = {}) ⇒ Object
- #get_feed_for_zipcode(zipcode, options = {}) ⇒ Object
- #get_response_for_woeid(woeid, options = {}) ⇒ Object
- #get_response_for_zipcode(zipcode, options = {}) ⇒ Object
-
#initialize ⇒ Client
constructor
A new instance of Client.
Constructor Details
#initialize ⇒ Client
Returns a new instance of Client.
6 7 8 |
# File 'lib/yweather/client.rb', line 6 def initialize @response = nil end |
Instance Attribute Details
#response ⇒ Object (readonly)
Returns the value of attribute response.
4 5 6 |
# File 'lib/yweather/client.rb', line 4 def response @response end |
Instance Method Details
#get_feed_for_woeid(woeid, options = {}) ⇒ Object
15 16 17 18 19 20 |
# File 'lib/yweather/client.rb', line 15 def get_feed_for_woeid(woeid, = {}) units = [:units] || 'f' format = [:format] || :json url = build_url(woeid, units) get(url, format) end |
#get_feed_for_zipcode(zipcode, options = {}) ⇒ Object
10 11 12 13 |
# File 'lib/yweather/client.rb', line 10 def get_feed_for_zipcode(zipcode, = {}) woeid = woeid_from_zipcode(zipcode) get_feed_for_woeid(woeid, ) end |
#get_response_for_woeid(woeid, options = {}) ⇒ Object
22 23 24 25 26 27 28 |
# File 'lib/yweather/client.rb', line 22 def get_response_for_woeid(woeid, = {}) units = [:units] || 'f' format = [:format] || :hash url = build_url(woeid, units) hash = get(url, format) @response = Response.new(woeid, nil, url, hash) end |
#get_response_for_zipcode(zipcode, options = {}) ⇒ Object
30 31 32 33 34 35 36 37 |
# File 'lib/yweather/client.rb', line 30 def get_response_for_zipcode(zipcode, = {}) units = [:units] || 'f' format = [:format] || :hash woeid = woeid_from_zipcode(zipcode) url = build_url(woeid, units) hash = get(url, format) @response = Response.new(woeid, zipcode, url, hash) end |