Class: WeatherGov::Alert

Inherits:
Feature show all
Defined in:
lib/weather_gov/alert.rb

Constant Summary collapse

SUMMARY_KEYS =
[
  "sent",
  "effective",
  "onset",
  "expires",
  "ends",
  "status",
  "severity",
  "certainty",
  "urgency",
  "event",
  "headline",
  "description",
  "instruction",
].freeze

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

#active?Boolean

Returns:

  • (Boolean)


37
38
39
# File 'lib/weather_gov/alert.rb', line 37

def active?
  active_time_range.include?(Time.now)
end

#active_time_rangeObject



33
34
35
# File 'lib/weather_gov/alert.rb', line 33

def active_time_range
  effective_time...expires_time
end

#effective_timeObject



25
26
27
# File 'lib/weather_gov/alert.rb', line 25

def effective_time
  Time.parse(properties.fetch("effective"))
end

#expires_timeObject



29
30
31
# File 'lib/weather_gov/alert.rb', line 29

def expires_time
  Time.parse(properties.fetch("expires"))
end

#sent_timeObject



21
22
23
# File 'lib/weather_gov/alert.rb', line 21

def sent_time
  Time.parse(properties.fetch("sent"))
end

#summary_hashObject



41
42
43
# File 'lib/weather_gov/alert.rb', line 41

def summary_hash
  properties.slice(*SUMMARY_KEYS)
end