Class: WeatherHandler::Weather

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

Constant Summary collapse

CELSIUM =
'celsium'

Instance Method Summary collapse

Constructor Details

#initialize(city) ⇒ Weather

Returns a new instance of Weather.



16
17
18
19
20
# 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

Instance Method Details

#current_temperature(dimension = CELSIUM) ⇒ Object



22
23
24
# File 'lib/weather_handler.rb', line 22

def current_temperature(dimension = CELSIUM)
  converter.new(dimension, kelvin_amount).call
end

#feels_like_temperature(dimension = CELSIUM) ⇒ Object



26
27
28
29
30
# 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

#humidityObject



36
37
38
# File 'lib/weather_handler.rb', line 36

def humidity
  "#{response.parsed_data['humidity']} %"
end

#pressureObject



40
41
42
# File 'lib/weather_handler.rb', line 40

def pressure
  "#{response.parsed_data['pressure']} mb"
end

#weather_descriptionObject



32
33
34
# File 'lib/weather_handler.rb', line 32

def weather_description
  response.parsed_weather_description
end