Class: FlightStats::DataFeed::File
- Inherits:
-
Object
- Object
- FlightStats::DataFeed::File
- Defined in:
- lib/flightstats/data_feed/file.rb
Defined Under Namespace
Classes: FlightUpdate, SaxParser
Instance Attribute Summary collapse
-
#bytes ⇒ Object
(also: #size)
Returns the value of attribute bytes.
-
#id ⇒ Object
Returns the value of attribute id.
-
#message_count ⇒ Object
Returns the value of attribute message_count.
-
#timestamp ⇒ Object
Returns the value of attribute timestamp.
Instance Method Summary collapse
- #content ⇒ Object
-
#initialize(content = nil, timestamp = nil) ⇒ File
constructor
A new instance of File.
- #updates(&block) ⇒ Object
Constructor Details
Instance Attribute Details
#bytes ⇒ Object Also known as: size
Returns the value of attribute bytes.
3 4 5 |
# File 'lib/flightstats/data_feed/file.rb', line 3 def bytes @bytes end |
#id ⇒ Object
Returns the value of attribute id.
3 4 5 |
# File 'lib/flightstats/data_feed/file.rb', line 3 def id @id end |
#message_count ⇒ Object
Returns the value of attribute message_count.
3 4 5 |
# File 'lib/flightstats/data_feed/file.rb', line 3 def @message_count end |
#timestamp ⇒ Object
Returns the value of attribute timestamp.
3 4 5 |
# File 'lib/flightstats/data_feed/file.rb', line 3 def @timestamp end |
Instance Method Details
#content ⇒ Object
11 12 13 14 15 16 |
# File 'lib/flightstats/data_feed/file.rb', line 11 def content if @content.nil? @content = FlightStats.query({:file => @id}, FlightStats::DataFeed::PATH) end @content end |
#updates(&block) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/flightstats/data_feed/file.rb', line 18 def updates(&block) parser = LibXML::XML::SaxParser.io(Zlib::GzipReader.new(content)) if block_given? parser.callbacks = SaxParser.new(@timestamp, &block) parser.parse else updates = [] parser.callbacks = SaxParser.new(@timestamp) { |update| updates << update } parser.parse updates end end |