Class: Request::HistoryBulk

Inherits:
Object
  • Object
show all
Defined in:
lib/ecraft-ow/request.rb

Overview

Clases segun API

Instance Method Summary collapse

Constructor Details

#initializeHistoryBulk

Returns a new instance of HistoryBulk.



11
12
13
14
# File 'lib/ecraft-ow/request.rb', line 11

def initialize
  @app_id = '1df2f62250291f78ccc5dabfec972da0'
  @base_url = 'http://api.openweathermap.org/data/2.5/'
end

Instance Method Details

#by_city(city) ⇒ Object



16
17
18
19
20
21
22
23
24
# File 'lib/ecraft-ow/request.rb', line 16

def by_city(city)
  url = URI("#{@base_url}weather?q=" + city + "&appid=#{@app_id}")
  http = Net::HTTP.new(url.host, url.port)
  request = Net::HTTP::Get.new(url)
  response = http.request(request)
  response = response.read_body
  response = JSON.parse(response)
  ap response
end