class Weatherr::Client
Constants
- ABSOLUTE_ZERO
- BASE_URL
Public Class Methods
new(opts = {})
click to toggle source
# File lib/weatherr.rb, line 9 def initialize(opts = {}) @api_key = opts[:api_key] end
Public Instance Methods
current(opts = {})
click to toggle source
# File lib/weatherr.rb, line 13 def current(opts = {}) params = { q: opts[:city_name], appid: @api_key } url = "#{BASE_URL}/weather" response = HTTP.get(url, params: params).parse return { temperature: (response['main']['temp'] + ABSOLUTE_ZERO).round(1), comment: response['weather'][0]['main'] } end