Class: Gull::Alert
- Inherits:
-
Object
- Object
- Gull::Alert
- Defined in:
- lib/gull/alert.rb
Overview
Represents a single NWS weather alert (warning, watch, or
advisory). Use Alert.fetch to retrieve active alerts from the
NWS API.
Instance Attribute Summary collapse
-
#alert_type ⇒ Object
Event type (e.g. "Tornado Warning").
-
#area ⇒ Object
Human-readable area description.
-
#certainty ⇒ Object
Certainty level as a Symbol.
-
#effective_at ⇒ Object
Time the alert takes effect.
-
#expires_at ⇒ Object
Time the alert expires.
-
#geocode ⇒ Object
Geocode with UGC and FIPS codes.
-
#id ⇒ Object
NWS alert identifier.
-
#link ⇒ Object
Canonical URL for this alert.
-
#polygon ⇒ Object
Alert area as a Polygon, or nil.
-
#published_at ⇒ Object
Time the alert was sent.
-
#severity ⇒ Object
Severity level as a Symbol.
-
#summary ⇒ Object
Full alert description text.
-
#title ⇒ Object
Alert headline.
-
#updated_at ⇒ Object
Onset time, or sent time if absent.
-
#urgency ⇒ Object
Urgency level as a Symbol.
-
#vtec ⇒ Object
VTEC string, or nil.
Class Method Summary collapse
-
.fetch(options = {}) ⇒ Object
Fetches active alerts from the NWS API.
Instance Method Summary collapse
-
#initialize ⇒ Alert
constructor
A new instance of Alert.
-
#parse(feature) ⇒ Object
Populates this alert from a GeoJSON feature hash.
Constructor Details
Instance Attribute Details
#alert_type ⇒ Object
Event type (e.g. "Tornado Warning")
24 25 26 27 |
# File 'lib/gull/alert.rb', line 24 attr_accessor :id, :title, :summary, :link, :alert_type, :polygon, :area, :effective_at, :expires_at, :updated_at, :published_at, :urgency, :severity, :certainty, :geocode, :vtec |
#area ⇒ Object
Human-readable area description
24 25 26 27 |
# File 'lib/gull/alert.rb', line 24 attr_accessor :id, :title, :summary, :link, :alert_type, :polygon, :area, :effective_at, :expires_at, :updated_at, :published_at, :urgency, :severity, :certainty, :geocode, :vtec |
#certainty ⇒ Object
Certainty level as a Symbol
24 25 26 27 |
# File 'lib/gull/alert.rb', line 24 attr_accessor :id, :title, :summary, :link, :alert_type, :polygon, :area, :effective_at, :expires_at, :updated_at, :published_at, :urgency, :severity, :certainty, :geocode, :vtec |
#effective_at ⇒ Object
Time the alert takes effect
24 25 26 27 |
# File 'lib/gull/alert.rb', line 24 attr_accessor :id, :title, :summary, :link, :alert_type, :polygon, :area, :effective_at, :expires_at, :updated_at, :published_at, :urgency, :severity, :certainty, :geocode, :vtec |
#expires_at ⇒ Object
Time the alert expires
24 25 26 27 |
# File 'lib/gull/alert.rb', line 24 attr_accessor :id, :title, :summary, :link, :alert_type, :polygon, :area, :effective_at, :expires_at, :updated_at, :published_at, :urgency, :severity, :certainty, :geocode, :vtec |
#geocode ⇒ Object
Geocode with UGC and FIPS codes
24 25 26 27 |
# File 'lib/gull/alert.rb', line 24 attr_accessor :id, :title, :summary, :link, :alert_type, :polygon, :area, :effective_at, :expires_at, :updated_at, :published_at, :urgency, :severity, :certainty, :geocode, :vtec |
#id ⇒ Object
NWS alert identifier
24 25 26 |
# File 'lib/gull/alert.rb', line 24 def id @id end |
#link ⇒ Object
Canonical URL for this alert
24 25 26 27 |
# File 'lib/gull/alert.rb', line 24 attr_accessor :id, :title, :summary, :link, :alert_type, :polygon, :area, :effective_at, :expires_at, :updated_at, :published_at, :urgency, :severity, :certainty, :geocode, :vtec |
#polygon ⇒ Object
Alert area as a Polygon, or nil
24 25 26 27 |
# File 'lib/gull/alert.rb', line 24 attr_accessor :id, :title, :summary, :link, :alert_type, :polygon, :area, :effective_at, :expires_at, :updated_at, :published_at, :urgency, :severity, :certainty, :geocode, :vtec |
#published_at ⇒ Object
Time the alert was sent
24 25 26 27 |
# File 'lib/gull/alert.rb', line 24 attr_accessor :id, :title, :summary, :link, :alert_type, :polygon, :area, :effective_at, :expires_at, :updated_at, :published_at, :urgency, :severity, :certainty, :geocode, :vtec |
#severity ⇒ Object
Severity level as a Symbol
24 25 26 27 |
# File 'lib/gull/alert.rb', line 24 attr_accessor :id, :title, :summary, :link, :alert_type, :polygon, :area, :effective_at, :expires_at, :updated_at, :published_at, :urgency, :severity, :certainty, :geocode, :vtec |
#summary ⇒ Object
Full alert description text
24 25 26 27 |
# File 'lib/gull/alert.rb', line 24 attr_accessor :id, :title, :summary, :link, :alert_type, :polygon, :area, :effective_at, :expires_at, :updated_at, :published_at, :urgency, :severity, :certainty, :geocode, :vtec |
#title ⇒ Object
Alert headline
24 25 26 27 |
# File 'lib/gull/alert.rb', line 24 attr_accessor :id, :title, :summary, :link, :alert_type, :polygon, :area, :effective_at, :expires_at, :updated_at, :published_at, :urgency, :severity, :certainty, :geocode, :vtec |
#updated_at ⇒ Object
Onset time, or sent time if absent
24 25 26 27 |
# File 'lib/gull/alert.rb', line 24 attr_accessor :id, :title, :summary, :link, :alert_type, :polygon, :area, :effective_at, :expires_at, :updated_at, :published_at, :urgency, :severity, :certainty, :geocode, :vtec |
#urgency ⇒ Object
Urgency level as a Symbol
24 25 26 27 |
# File 'lib/gull/alert.rb', line 24 attr_accessor :id, :title, :summary, :link, :alert_type, :polygon, :area, :effective_at, :expires_at, :updated_at, :published_at, :urgency, :severity, :certainty, :geocode, :vtec |
#vtec ⇒ Object
VTEC string, or nil
24 25 26 27 |
# File 'lib/gull/alert.rb', line 24 attr_accessor :id, :title, :summary, :link, :alert_type, :polygon, :area, :effective_at, :expires_at, :updated_at, :published_at, :urgency, :severity, :certainty, :geocode, :vtec |
Class Method Details
Instance Method Details
#parse(feature) ⇒ Object
Populates this alert from a GeoJSON feature hash.
40 41 42 43 44 45 46 47 48 |
# File 'lib/gull/alert.rb', line 40 def parse(feature) props = feature['properties'] parse_core_attributes(feature, props) parse_times(props) parse_categories(props) parse_polygon(feature) parse_geocode(props) parse_vtec(props) end |