Class: WeatherGov::Forecast
Instance Attribute Summary
Attributes inherited from Feature
#client
Instance Method Summary
collapse
Methods inherited from Feature
#context, #data, #geometry, #id, #initialize, #properties, #type
Instance Method Details
#current ⇒ Object
23
24
25
|
# File 'lib/weather_gov/forecast.rb', line 23
def current
periods.find { |p| (p.start_time...p.end_time).include?(Time.now) }
end
|
#periods ⇒ Object
19
20
21
|
# File 'lib/weather_gov/forecast.rb', line 19
def periods
properties.fetch("periods").map { |period| ForecastPeriod.new(data: period) }
end
|
#update_time ⇒ Object
7
8
9
|
# File 'lib/weather_gov/forecast.rb', line 7
def update_time
@update_time ||= Time.parse(properties.fetch("updateTime"))
end
|
#valid? ⇒ Boolean
15
16
17
|
# File 'lib/weather_gov/forecast.rb', line 15
def valid?
valid_time.valid?
end
|
#valid_time ⇒ Object
11
12
13
|
# File 'lib/weather_gov/forecast.rb', line 11
def valid_time
@valid_time ||= ValidTime.parse(properties.fetch("validTimes"))
end
|