Class: OpenWeatherLite::Weather
- Inherits:
-
Object
- Object
- OpenWeatherLite::Weather
- Defined in:
- lib/open_weather_lite/weather.rb
Overview
Look up current weather conditions by available api calls
all methods return parsed json response objects
Constant Summary collapse
- VERSION =
'2.5'
- BASE_URL =
'http://api.openweathermap.org/data/'
Instance Attribute Summary collapse
-
#api_key ⇒ Object
Returns the value of attribute api_key.
-
#units ⇒ Object
Returns the value of attribute units.
-
#version ⇒ Object
Returns the value of attribute version.
Instance Method Summary collapse
- #by_city_id(city_id) ⇒ Object
- #by_coords(latitude, longitude) ⇒ Object
- #by_zip_code(zip_code, country = 'us') ⇒ Object
-
#initialize(api_key = nil) ⇒ Weather
constructor
A new instance of Weather.
Constructor Details
Instance Attribute Details
#api_key ⇒ Object
Returns the value of attribute api_key.
7 8 9 |
# File 'lib/open_weather_lite/weather.rb', line 7 def api_key @api_key end |
#units ⇒ Object
Returns the value of attribute units.
7 8 9 |
# File 'lib/open_weather_lite/weather.rb', line 7 def units @units end |
#version ⇒ Object
Returns the value of attribute version.
7 8 9 |
# File 'lib/open_weather_lite/weather.rb', line 7 def version @version end |
Instance Method Details
#by_city_id(city_id) ⇒ Object
18 19 20 |
# File 'lib/open_weather_lite/weather.rb', line 18 def by_city_id(city_id) run(id: city_id) end |
#by_coords(latitude, longitude) ⇒ Object
22 23 24 |
# File 'lib/open_weather_lite/weather.rb', line 22 def by_coords(latitude, longitude) run(lat: latitude, lon: longitude) end |
#by_zip_code(zip_code, country = 'us') ⇒ Object
14 15 16 |
# File 'lib/open_weather_lite/weather.rb', line 14 def by_zip_code(zip_code, country = 'us') run(zip: "#{zip_code},#{country}") end |