Class: FAA::DelayFeed
- Inherits:
-
Object
- Object
- FAA::DelayFeed
- Defined in:
- lib/faa/delay_feed.rb
Constant Summary collapse
- FEED_URI =
'http://www.fly.faa.gov/flyfaa/xmlAirportStatus.jsp'
- END_TAG =
'</AIRPORT_STATUS_INFORMATION>'
Instance Attribute Summary collapse
-
#delays ⇒ Object
readonly
Returns the value of attribute delays.
-
#raw ⇒ Object
readonly
Returns the value of attribute raw.
-
#updated_at ⇒ Object
readonly
Returns the value of attribute updated_at.
Class Method Summary collapse
- .current_delays ⇒ Object
-
.raw_feed ⇒ Object
A StringIO object with the raw xml feed.
-
.uri ⇒ Object
The URI of the feed.
Instance Method Summary collapse
-
#initialize(raw = nil) ⇒ DelayFeed
constructor
A new instance of DelayFeed.
- #parse_xml_feed ⇒ Object
Constructor Details
Instance Attribute Details
#delays ⇒ Object (readonly)
Returns the value of attribute delays.
5 6 7 |
# File 'lib/faa/delay_feed.rb', line 5 def delays @delays end |
#raw ⇒ Object (readonly)
Returns the value of attribute raw.
5 6 7 |
# File 'lib/faa/delay_feed.rb', line 5 def raw @raw end |
#updated_at ⇒ Object (readonly)
Returns the value of attribute updated_at.
5 6 7 |
# File 'lib/faa/delay_feed.rb', line 5 def updated_at @updated_at end |
Class Method Details
.current_delays ⇒ Object
43 44 45 |
# File 'lib/faa/delay_feed.rb', line 43 def current_delays self.new.delays end |
.raw_feed ⇒ Object
A StringIO object with the raw xml feed
38 39 40 41 |
# File 'lib/faa/delay_feed.rb', line 38 def raw_feed http = Net::HTTP.new(uri.host, uri.port) StringIO.new(http.get(uri.path).body) end |
.uri ⇒ Object
The URI of the feed.
33 34 35 |
# File 'lib/faa/delay_feed.rb', line 33 def uri @uri ||= URI.parse(FEED_URI) end |
Instance Method Details
#parse_xml_feed ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/faa/delay_feed.rb', line 14 def parse_xml_feed = {:options => LibXML::XML::Parser::Options::NOBLANKS} document = LibXML::XML::Parser.string(@raw, ).parse document.root.children.each do |node| case node.name when 'Update_Time' node.content =~ /([a-z]+) (\d+) (\d{2}):(\d{2}):(\d{2}) (\d{4})/i @updated_at = Time.utc($6.to_i, Date::ABBR_MONTHNAMES.index($1), $2.to_i, $3.to_i, $4.to_i, $5.to_i) when 'Delay_type' @delays += FAA::Delay.from_xml(node, @updated_at) end end end |