Class: OpenWeatherLite::Weather

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

Constructor Details

#initialize(api_key = nil) ⇒ Weather

Returns a new instance of Weather.



9
10
11
12
# File 'lib/open_weather_lite/weather.rb', line 9

def initialize(api_key = nil)
  @api_key = api_key
  @version = VERSION
end

Instance Attribute Details

#api_keyObject

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

#unitsObject

Returns the value of attribute units.



7
8
9
# File 'lib/open_weather_lite/weather.rb', line 7

def units
  @units
end

#versionObject

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