Class: Eancom::Parser::Segment

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(string) ⇒ Segment

Returns a new instance of Segment.



7
8
9
10
# File 'lib/eancom/parser/segment.rb', line 7

def initialize(string)
  @string = string
  @components = []
end

Instance Attribute Details

#componentsObject

Returns the value of attribute components.



5
6
7
# File 'lib/eancom/parser/segment.rb', line 5

def components
  @components
end

#stringObject

Returns the value of attribute string.



5
6
7
# File 'lib/eancom/parser/segment.rb', line 5

def string
  @string
end

#tag=(value) ⇒ Object

Sets the attribute tag

Parameters:

  • value

    the value to set the attribute tag to.



5
6
7
# File 'lib/eancom/parser/segment.rb', line 5

def tag=(value)
  @tag = value
end

Instance Method Details

#parseObject



12
13
14
15
16
17
# File 'lib/eancom/parser/segment.rb', line 12

def parse
  parse_component
  klass = find_segment_class
  structure = find_structure
  klass.initialize_by_components(structure, @components)
end