class WeatherHandler::Weather

Constants

CELSIUM

Attributes

converter[R]
kelvin_amount[R]
response[R]

Public Class Methods

new(city) click to toggle source
# File lib/weather_handler.rb, line 16
def initialize(city)
  @response = OpenWeatherClient.new(city).call
  @converter = Adapters::Weather
  @kelvin_amount = response.amount_in_kelvins
end

Public Instance Methods

current_temperature(dimension = CELSIUM) click to toggle source
# File lib/weather_handler.rb, line 22
def current_temperature(dimension = CELSIUM)
  converter.new(dimension, kelvin_amount).call
end
feels_like_temperature(dimension = CELSIUM) click to toggle source
# File lib/weather_handler.rb, line 26
def feels_like_temperature(dimension = CELSIUM)
  amount = (response.parsed_data['feels_like']).round(1)

  converter.new(dimension, amount).call
end
humidity() click to toggle source
# File lib/weather_handler.rb, line 36
def humidity
  "#{response.parsed_data['humidity']} %"
end
pressure() click to toggle source
# File lib/weather_handler.rb, line 40
def pressure
  "#{response.parsed_data['pressure']} mb"
end
weather_description() click to toggle source
# File lib/weather_handler.rb, line 32
def weather_description
  response.parsed_weather_description
end