Class: OpenWeatherAPI::API
- Inherits:
-
Object
- Object
- OpenWeatherAPI::API
- Defined in:
- lib/open-weather-api/api.rb
Constant Summary collapse
- VERSION =
"2.5"
Instance Attribute Summary collapse
-
#api_key ⇒ Object
Returns the value of attribute api_key.
-
#default_country_code ⇒ Object
Returns the value of attribute default_country_code.
-
#default_language ⇒ Object
Returns the value of attribute default_language.
-
#default_units ⇒ Object
Returns the value of attribute default_units.
Instance Method Summary collapse
- #current(**args, &block) ⇒ Object
-
#forecast(type = :hourly, **args, &block) ⇒ Object
Not yet implemented.
- #icon_url(icon_code) ⇒ Object
-
#initialize(options = {}) ⇒ API
constructor
A new instance of API.
Constructor Details
#initialize(options = {}) ⇒ API
Returns a new instance of API.
8 9 10 11 12 13 |
# File 'lib/open-weather-api/api.rb', line 8 def initialize( = {}) @api_key = [:api_key] || ['api_key'] @default_language = [:default_language] || ['default_language'] || 'en' @default_country_code = [:default_country_code] || ['default_country_code'] @default_units = [:default_units] || ['default_units'] || 'metric' end |
Instance Attribute Details
#api_key ⇒ Object
Returns the value of attribute api_key.
6 7 8 |
# File 'lib/open-weather-api/api.rb', line 6 def api_key @api_key end |
#default_country_code ⇒ Object
Returns the value of attribute default_country_code.
6 7 8 |
# File 'lib/open-weather-api/api.rb', line 6 def default_country_code @default_country_code end |
#default_language ⇒ Object
Returns the value of attribute default_language.
6 7 8 |
# File 'lib/open-weather-api/api.rb', line 6 def default_language @default_language end |
#default_units ⇒ Object
Returns the value of attribute default_units.
6 7 8 |
# File 'lib/open-weather-api/api.rb', line 6 def default_units @default_units end |
Instance Method Details
#current(**args, &block) ⇒ Object
15 16 17 |
# File 'lib/open-weather-api/api.rb', line 15 def current(**args, &block) fetch_current.execute(**args, &block) end |
#forecast(type = :hourly, **args, &block) ⇒ Object
Not yet implemented
20 21 22 |
# File 'lib/open-weather-api/api.rb', line 20 def forecast(type = :hourly, **args, &block) self.send("fetch_forecast_#{type}").execute(**args, &block) end |
#icon_url(icon_code) ⇒ Object
24 25 26 |
# File 'lib/open-weather-api/api.rb', line 24 def icon_url(icon_code) "http://openweathermap.org/img/w/#{icon_code}.png" end |