Class: Gull::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/gull/client.rb

Overview

Client exposes methods and options for fetching alerts from the NWS/NOAA web service

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Client

Returns a new instance of Client.



10
11
12
13
14
15
# File 'lib/gull/client.rb', line 10

def initialize(options = {})
  @options = {
    url: 'http://alerts.weather.gov/cap/us.php?x=1',
    strict: false
  }.merge options
end

Instance Attribute Details

#errorsObject

Returns the value of attribute errors.



8
9
10
# File 'lib/gull/client.rb', line 8

def errors
  @errors
end

Instance Method Details

#fetchObject



17
18
19
20
21
22
23
24
# File 'lib/gull/client.rb', line 17

def fetch
  self.errors = []
  content = response
  document = Nokogiri::XML content do |config|
    config.strict if @options[:strict]
  end
  process document.xpath('//xmlns:feed/xmlns:entry', namespaces)
end