Class: EdifactConverter::EDI2XML11::ParentGroupHandler

Inherits:
EdifactConverter::EmptyHandler show all
Defined in:
lib/edifact_converter/edi2xml11/parent_group_handler.rb

Instance Attribute Summary collapse

Attributes inherited from EdifactConverter::EmptyHandler

#locator, #next_handler

Instance Method Summary collapse

Methods inherited from EdifactConverter::EmptyHandler

#initialize, #method_missing

Constructor Details

This class inherits a constructor from EdifactConverter::EmptyHandler

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class EdifactConverter::EmptyHandler

Instance Attribute Details

#ancestorsObject

Returns the value of attribute ancestors.



7
8
9
# File 'lib/edifact_converter/edi2xml11/parent_group_handler.rb', line 7

def ancestors
  @ancestors
end

Instance Method Details

#endSegmentGroup(name) ⇒ Object



27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/edifact_converter/edi2xml11/parent_group_handler.rb', line 27

def endSegmentGroup(name)
  if name == 'BrevIndhold'
    ancestors.reverse_each do |parent|
      super(parent)
    end
    super
    self.ancestors = nil
  elsif locator.rules.children.any?
    ancestors << name
  else
    super
  end
end

#startSegmentGroup(name, hidden = false) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/edifact_converter/edi2xml11/parent_group_handler.rb', line 13

def startSegmentGroup(name, hidden = false)
  if ancestors
    self.ancestors = ancestors.drop_while do |parent_group|         
      if locator.rules.child?(name)
        false
      else
        next_handler.endSegmentGroup(parent_group)
        true
      end
    end
  end
  super
end