Class: Yapi::Weather
- Inherits:
-
Object
- Object
- Yapi::Weather
- Defined in:
- lib/yapi/weather.rb
Instance Attribute Summary collapse
-
#config ⇒ Object
Returns the value of attribute config.
Instance Method Summary collapse
- #configure(options = {}) ⇒ Object
-
#initialize(api_key) ⇒ Weather
constructor
A new instance of Weather.
- #place(coordinates) ⇒ Object
Constructor Details
Instance Attribute Details
#config ⇒ Object
Returns the value of attribute config.
7 8 9 |
# File 'lib/yapi/weather.rb', line 7 def config @config end |
Instance Method Details
#configure(options = {}) ⇒ Object
14 15 16 17 18 |
# File 'lib/yapi/weather.rb', line 14 def configure( = {}) .each do |key, value| self.config[key] = value end end |
#place(coordinates) ⇒ Object
20 21 22 23 |
# File 'lib/yapi/weather.rb', line 20 def place coordinates req_url = "http://weather.olp.yahooapis.jp/v1/place?appid=#{@client.get_api_key}#{@client.build_url(self.config)}&coordinates=#{coordinates}" return @client.xml_to_json(open(URI.encode(req_url)).read) end |