Class: Hotfile
- Inherits:
-
Object
- Object
- Hotfile
- Includes:
- Parser, Transaction
- Defined in:
- lib/hotfile.rb,
lib/hotfile/date.rb,
lib/hotfile/parser.rb,
lib/hotfile/record.rb,
lib/hotfile/string.rb,
lib/hotfile/integer.rb,
lib/hotfile/transaction.rb,
lib/hotfile/record/BAR64.rb,
lib/hotfile/record/BAR65.rb,
lib/hotfile/record/BAR66.rb,
lib/hotfile/record/BAR67.rb,
lib/hotfile/record/BCC82.rb,
lib/hotfile/record/BCH02.rb,
lib/hotfile/record/BCT95.rb,
lib/hotfile/record/BCX83.rb,
lib/hotfile/record/BFH01.rb,
lib/hotfile/record/BFT99.rb,
lib/hotfile/record/BKF81.rb,
lib/hotfile/record/BKI61.rb,
lib/hotfile/record/BKI62.rb,
lib/hotfile/record/BKI63.rb,
lib/hotfile/record/BKP84.rb,
lib/hotfile/record/BKS24.rb,
lib/hotfile/record/BKS30.rb,
lib/hotfile/record/BKS31.rb,
lib/hotfile/record/BKS39.rb,
lib/hotfile/record/BKS42.rb,
lib/hotfile/record/BKS45.rb,
lib/hotfile/record/BKS46.rb,
lib/hotfile/record/BKS47.rb,
lib/hotfile/record/BKT06.rb,
lib/hotfile/record/BOH03.rb,
lib/hotfile/record/BOT93.rb,
lib/hotfile/record/BOT94.rb,
lib/hotfile/record/record.rb
Overview
Main class
Defined Under Namespace
Modules: Parser, Transaction Classes: Date, Integer, Record, String
Constant Summary collapse
- LINE_LENGTH =
136
Instance Method Summary collapse
-
#initialize(file = nil) ⇒ Hotfile
constructor
A new instance of Hotfile.
- #records ⇒ Object (also: #lines)
- #size ⇒ Object (also: #length, #count)
Methods included from Transaction
#find_pnr, #flight_schedule, #passengers, #summarize_transaction, #transactions
Methods included from Parser
#parse, #parse_line, #unparsable
Constructor Details
#initialize(file = nil) ⇒ Hotfile
Returns a new instance of Hotfile.
18 19 20 21 22 23 24 25 |
# File 'lib/hotfile.rb', line 18 def initialize(file = nil) @file = if file.respond_to? :read file.read elsif file File.read file end @file = @file.delete("\r") if @file end |
Instance Method Details
#records ⇒ Object Also known as: lines
33 34 35 |
# File 'lib/hotfile.rb', line 33 def records @file&.lines(chomp: true)&.count end |
#size ⇒ Object Also known as: length, count
27 28 29 |
# File 'lib/hotfile.rb', line 27 def size @file&.size end |