Class: Forecaster
- Inherits:
-
Object
- Object
- Forecaster
- Defined in:
- lib/meteorologist/forecaster.rb
Constant Summary collapse
- DARKSKY_URL =
"https://api.darksky.net/forecast"
Instance Method Summary collapse
- #apparent_maximum_temperature ⇒ Object
- #apparent_minimum_temperature ⇒ Object
- #current_apparent_temperature ⇒ Object
- #current_humidity ⇒ Object
- #current_summary ⇒ Object
- #current_temperature ⇒ Object
-
#initialize(coordinates, units, forecast_time, options = {}) ⇒ Forecaster
constructor
A new instance of Forecaster.
- #maximum_temperature ⇒ Object
- #minimum_temperature ⇒ Object
- #moon_phase ⇒ Object
- #sunrise ⇒ Object
- #sunset ⇒ Object
- #todays_summary ⇒ Object
Constructor Details
#initialize(coordinates, units, forecast_time, options = {}) ⇒ Forecaster
Returns a new instance of Forecaster.
5 6 7 8 |
# File 'lib/meteorologist/forecaster.rb', line 5 def initialize(coordinates, units, forecast_time, = {}) data = .fetch(:data) { get_data(coordinates, units, forecast_time) } @forecast = validate_and_parse(data) end |
Instance Method Details
#apparent_maximum_temperature ⇒ Object
54 55 56 |
# File 'lib/meteorologist/forecaster.rb', line 54 def apparent_maximum_temperature todays('apparentTemperatureMax') end |
#apparent_minimum_temperature ⇒ Object
46 47 48 |
# File 'lib/meteorologist/forecaster.rb', line 46 def apparent_minimum_temperature todays('apparentTemperatureMin') end |
#current_apparent_temperature ⇒ Object
18 19 20 |
# File 'lib/meteorologist/forecaster.rb', line 18 def current_apparent_temperature current('apparentTemperature') end |
#current_humidity ⇒ Object
22 23 24 |
# File 'lib/meteorologist/forecaster.rb', line 22 def current_humidity "#{(current('humidity') * 100).to_i}%" end |
#current_summary ⇒ Object
10 11 12 |
# File 'lib/meteorologist/forecaster.rb', line 10 def current_summary current('summary') end |
#current_temperature ⇒ Object
14 15 16 |
# File 'lib/meteorologist/forecaster.rb', line 14 def current_temperature current('temperature') end |
#maximum_temperature ⇒ Object
50 51 52 |
# File 'lib/meteorologist/forecaster.rb', line 50 def maximum_temperature todays('temperatureMax') end |
#minimum_temperature ⇒ Object
42 43 44 |
# File 'lib/meteorologist/forecaster.rb', line 42 def minimum_temperature todays('temperatureMin') end |
#moon_phase ⇒ Object
38 39 40 |
# File 'lib/meteorologist/forecaster.rb', line 38 def moon_phase todays('moonPhase') end |
#sunrise ⇒ Object
30 31 32 |
# File 'lib/meteorologist/forecaster.rb', line 30 def sunrise get_time(todays('sunriseTime')) end |
#sunset ⇒ Object
34 35 36 |
# File 'lib/meteorologist/forecaster.rb', line 34 def sunset get_time(todays('sunsetTime')) end |
#todays_summary ⇒ Object
26 27 28 |
# File 'lib/meteorologist/forecaster.rb', line 26 def todays_summary todays('summary') end |