Class: Eancom::Parser::Document
- Inherits:
-
Object
- Object
- Eancom::Parser::Document
- Defined in:
- lib/eancom/parser/document.rb
Defined Under Namespace
Classes: SegmentTypeNotDefined
Instance Attribute Summary collapse
-
#document ⇒ Object
readonly
Returns the value of attribute document.
-
#file ⇒ Object
readonly
Returns the value of attribute file.
Instance Method Summary collapse
-
#initialize(file:) ⇒ Document
constructor
A new instance of Document.
- #parse(header_only: false) ⇒ Object
Constructor Details
Instance Attribute Details
#document ⇒ Object (readonly)
Returns the value of attribute document.
8 9 10 |
# File 'lib/eancom/parser/document.rb', line 8 def document @document end |
#file ⇒ Object (readonly)
Returns the value of attribute file.
8 9 10 |
# File 'lib/eancom/parser/document.rb', line 8 def file @file end |
Instance Method Details
#parse(header_only: false) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/eancom/parser/document.rb', line 15 def parse(header_only: false) content.split(segment_delimiter).each do |segment_string| segment = Parser::Segment.new(segment_string) if header_only && segment.segment_class::TYPE != :header next end segment = segment.parse add(segment) end @document end |