Class: Weatherstorm::Forecast

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

Overview

Gets the forecast for a location

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args) ⇒ Forecast

Returns a new instance of Forecast.



7
8
9
10
11
12
# File 'lib/weatherstorm/forecast.rb', line 7

def initialize(args)
  @location = args.fetch(:location)
  @time = args.fetch(:time)
  @api = args[:api_key]
  ForecastIO.api_key = api
end

Instance Attribute Details

#apiObject (readonly)

Returns the value of attribute api.



6
7
8
# File 'lib/weatherstorm/forecast.rb', line 6

def api
  @api
end

#locationObject (readonly)

Returns the value of attribute location.



6
7
8
# File 'lib/weatherstorm/forecast.rb', line 6

def location
  @location
end

#timeObject (readonly)

Returns the value of attribute time.



6
7
8
# File 'lib/weatherstorm/forecast.rb', line 6

def time
  @time
end

Class Method Details

.at(args) ⇒ Object



14
15
16
17
18
19
20
# File 'lib/weatherstorm/forecast.rb', line 14

def self.at(args)
  Forecast.new(
    location: args.fetch(:location, 'Atlanta'),
    time: args.fetch(:time, DateTime.now),
    api_key: args.fetch(:api_key)
  )
end