Class: Headache::DocumentParser
- Inherits:
-
Object
- Object
- Headache::DocumentParser
- Defined in:
- lib/headache/document_parser.rb
Constant Summary collapse
- LINE_SEPARATOR =
"\r\n".freeze
Instance Method Summary collapse
-
#initialize(string_or_file) ⇒ DocumentParser
constructor
A new instance of DocumentParser.
- #parse ⇒ Object
Constructor Details
#initialize(string_or_file) ⇒ DocumentParser
Returns a new instance of DocumentParser.
5 6 7 |
# File 'lib/headache/document_parser.rb', line 5 def initialize(string_or_file) @ach_string = string_or_file.respond_to?(:read) ? string_or_file.read : string_or_file end |
Instance Method Details
#parse ⇒ Object
9 10 11 12 13 14 15 16 17 |
# File 'lib/headache/document_parser.rb', line 9 def parse fail Headache::InvalidRecordType, if invalid_ach? Headache::Document.new( Record::FileHeader.new(nil).parse(records.shift), Record::FileControl.new(nil).parse(records.pop), get_batches.map { |b| Headache::Batch.new(self).parse(b) } ) end |