Class: Forecastr::Client

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

Constant Summary collapse

API_URL =
"http://api.openweathermap.org/data/2.5/weather?"

Class Method Summary collapse

Class Method Details

.search_by_city(city_name) ⇒ Object



9
10
11
12
13
# File 'lib/forecastr/client.rb', line 9

def search_by_city(city_name)
  uri = URI(API_URL + "q=" + city_name)
  json = JSON.parse(Net::HTTP.get(uri))
  Forecastr::DataContainer.new(json)
end

.search_by_coordinates(lat, lon) ⇒ Object



15
16
17
18
19
# File 'lib/forecastr/client.rb', line 15

def search_by_coordinates(lat, lon)
  uri = URI(API_URL + "lat=#{lat}&lon=#{lon}")
  json = JSON.parse(Net::HTTP.get(uri))
  Forecastr::DataContainer.new(json)
end