Sha256: 734f8b2380f1fa1508110abb002a79a9e03678ba1f4a8b87bad87cfd0028c7ac

Contents?: true

Size: 656 Bytes

Versions: 1

Compression:

Stored size: 656 Bytes

Contents

require "noaa-alerts/version"

module Noaa
  class Alert
    attr_reader :description, :locations, :identifier, :effective_at, :expires_at

    def initialize(entry)
      @description = ""
      @locations = []
      @identifier = ""
      @effective_at = nil
      @expires_at = nil
      handle_entry(entry)
    end

    private
    
    def handle_entry(entry)
      @description = entry['info']['description']
      @locations = entry['info']['area']['areaDesc'].split('; ')
      @identifier = entry['identifier']
      @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.0.2 lib/alert.rb