Class: Gull::Alert

Inherits:
Object
  • Object
show all
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

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeAlert

Returns a new instance of Alert.



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

def initialize
  self.geocode = Geocode.new
end

Instance Attribute Details

#alert_typeObject

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

#areaObject

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

#certaintyObject

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_atObject

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_atObject

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

#geocodeObject

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

#idObject

NWS alert identifier



24
25
26
# File 'lib/gull/alert.rb', line 24

def id
  @id
end

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

#polygonObject

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_atObject

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

#severityObject

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

#summaryObject

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

#titleObject

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_atObject

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

#urgencyObject

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

#vtecObject

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

.fetch(options = {}) ⇒ Object

Fetches active alerts from the NWS API.



34
35
36
37
# File 'lib/gull/alert.rb', line 34

def self.fetch(options = {})
  client = Client.new(options)
  client.fetch
end

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