Class: Yweather::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/yweather/client.rb

Constant Summary collapse

@@BASE_URL =
"http://weather.yahooapis.com/forecastrss"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeClient

Returns a new instance of Client.



6
7
8
# File 'lib/yweather/client.rb', line 6

def initialize
  @response = nil
end

Instance Attribute Details

#responseObject (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, options = {})
  units = options[:units] || 'f'
  format = options[: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, options = {})
  woeid = woeid_from_zipcode(zipcode)
  get_feed_for_woeid(woeid, options)
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, options = {})
  units = options[:units] || 'f'
  format = options[: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, options = {})
  units = options[:units] || 'f'
  format = options[:format] || :hash
  woeid = woeid_from_zipcode(zipcode)
  url = build_url(woeid, units)
  hash = get(url, format)
  @response = Response.new(woeid, zipcode, url, hash)
end