Class: MyWeatherForecast

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

Overview

This gem is a wrapper of the forecast_io gem SI explained: en.wikipedia.org/wiki/SI_derived_unit

Defined Under Namespace

Classes: Day, DaysAhead

Instance Method Summary collapse

Constructor Details

#initialize(lat, lon, api_key: nil, si: true) ⇒ MyWeatherForecast

Returns a new instance of MyWeatherForecast.



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/myweatherforecast.rb', line 12

def initialize(lat, lon, api_key: nil, si: true)

  ForecastIO.api_key = api_key


  if si then
    params = { units: 'si' }
    @tlabel = 'degrees Celcius'
  else 
    params = {}
    @tlabel = 'degrees Farenheit'
  end

  @forecast = ForecastIO.forecast(lat, lon, params: params)
end

Instance Method Details

#todayObject



69
70
71
# File 'lib/myweatherforecast.rb', line 69

def today()
  Day.new(@forecast.currently, @tlabel)
end

#tomorrowObject



73
74
75
# File 'lib/myweatherforecast.rb', line 73

def tomorrow()
  DaysAhead.new(@forecast['daily']['data'][1], @tlabel)
end