Class: Eancom::Parser::Document

Inherits:
Object
  • Object
show all
Defined in:
lib/eancom/parser/document.rb

Defined Under Namespace

Classes: SegmentTypeNotDefined

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(file:) ⇒ Document

Returns a new instance of Document.



8
9
10
11
# File 'lib/eancom/parser/document.rb', line 8

def initialize(file:)
  @file = file
  @document = Eancom::Edifact::Document.new
end

Instance Attribute Details

#documentObject (readonly)

Returns the value of attribute document.



6
7
8
# File 'lib/eancom/parser/document.rb', line 6

def document
  @document
end

#fileObject (readonly)

Returns the value of attribute file.



6
7
8
# File 'lib/eancom/parser/document.rb', line 6

def file
  @file
end

Instance Method Details

#parseObject



13
14
15
16
17
18
19
20
# File 'lib/eancom/parser/document.rb', line 13

def parse
  content.split(segment_delimiter).each do |segment_string|
    segment = Parser::Segment.new(segment_string)
    segment = segment.parse
    add(segment)
  end
  @document
end