Class: WeatherGov::Forecast

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

Instance Attribute Summary

Attributes inherited from Feature

#client

Instance Method Summary collapse

Methods inherited from Feature

#context, #data, #geometry, #id, #initialize, #properties, #type

Constructor Details

This class inherits a constructor from WeatherGov::Feature

Instance Method Details

#currentObject



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

#periodsObject



19
20
21
# File 'lib/weather_gov/forecast.rb', line 19

def periods
  properties.fetch("periods").map { |period| ForecastPeriod.new(data: period) }
end

#update_timeObject



7
8
9
# File 'lib/weather_gov/forecast.rb', line 7

def update_time
  @update_time ||= Time.parse(properties.fetch("updateTime"))
end

#valid?Boolean

Returns:

  • (Boolean)


15
16
17
# File 'lib/weather_gov/forecast.rb', line 15

def valid?
  valid_time.valid?
end

#valid_timeObject



11
12
13
# File 'lib/weather_gov/forecast.rb', line 11

def valid_time
  @valid_time ||= ValidTime.parse(properties.fetch("validTimes"))
end