Class: Request::HistoryBulk
- Inherits:
-
Object
- Object
- Request::HistoryBulk
- Defined in:
- lib/ecraft-ow/request.rb
Overview
Clases segun API
Instance Method Summary collapse
- #by_city(city) ⇒ Object
-
#initialize ⇒ HistoryBulk
constructor
A new instance of HistoryBulk.
Constructor Details
#initialize ⇒ HistoryBulk
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 |