Sha256: 7504c821248a3dcc0f83c9c3cdc463a88e77cd041c204723812e6c7a59d2a448

Contents?: true

Size: 1017 Bytes

Versions: 1

Compression:

Stored size: 1017 Bytes

Contents

require "noaa-alerts/version"

module Noaa
  class Alert
    attr_reader :description, :locations, :identifier, :effective_at, :expires_at, :event, :urgency, :severity, :headline, :sent_at

    def initialize(entry)
      @description = ""
      @event = ""
      @urgency = ""
      @severity = ""
      @headline = ""
      @locations = []
      @identifier = ""
      @effective_at = nil
      @expires_at = nil
      @sent_at = nil
      handle_entry(entry)
    end

    private
    
    def handle_entry(entry)
      @description = entry['info']['description']
      @event = entry['info']['event']
      @urgency= entry['info']['urgency']
      @severity = entry['info']['severity']
      @headline = entry['info']['headline']
      @locations = entry['info']['area']['areaDesc'].split('; ')
      @identifier = entry['identifier']
      @sent_at = Time.parse(entry['sent'])
      @effective_at = Time.parse(entry['info']['effective'])
      @expires_at = Time.parse(entry['info']['expires'])
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
noaa-alerts-0.1.1 lib/alert.rb