Class: DtaParser::File
- Inherits:
-
Object
- Object
- DtaParser::File
- Defined in:
- lib/dta_parser/file.rb
Instance Attribute Summary collapse
-
#booking_records ⇒ Object
Returns the value of attribute booking_records.
-
#footer_record ⇒ Object
Returns the value of attribute footer_record.
-
#header_record ⇒ Object
Returns the value of attribute header_record.
-
#raw ⇒ Object
Returns the value of attribute raw.
Instance Method Summary collapse
-
#initialize(filename) ⇒ File
constructor
A new instance of File.
Constructor Details
#initialize(filename) ⇒ File
Returns a new instance of File.
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/dta_parser/file.rb', line 7 def initialize(filename) self.raw = ::File.open(filename, "r") { |f| f.read } self.booking_records ||= [] records.each do |record| record_type = record[4, 1] case record_type when "A" self.header_record = DtaParser::HeaderRecord.new(record) when "C" self.booking_records << DtaParser::BookingRecord.new(record) when "E" self. = DtaParser::FooterRecord.new(record) else raise "Unknown record type: #{record_type}" end end end |
Instance Attribute Details
#booking_records ⇒ Object
Returns the value of attribute booking_records.
5 6 7 |
# File 'lib/dta_parser/file.rb', line 5 def booking_records @booking_records end |
#footer_record ⇒ Object
Returns the value of attribute footer_record.
5 6 7 |
# File 'lib/dta_parser/file.rb', line 5 def @footer_record end |
#header_record ⇒ Object
Returns the value of attribute header_record.
5 6 7 |
# File 'lib/dta_parser/file.rb', line 5 def header_record @header_record end |
#raw ⇒ Object
Returns the value of attribute raw.
5 6 7 |
# File 'lib/dta_parser/file.rb', line 5 def raw @raw end |