Class: EdifactConverter::EDI2XML11::SegmentGroupHandler

Inherits:
EdifactConverter::EmptyHandler show all
Defined in:
lib/edifact_converter/edi2xml11/segment_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

#indholdObject Also known as: indhold?

Returns the value of attribute indhold.



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

def indhold
  @indhold
end

Instance Method Details

#endSegment(name) ⇒ Object



32
33
34
# File 'lib/edifact_converter/edi2xml11/segment_group_handler.rb', line 32

def endSegment(name)
	super unless indhold? and name =~ /S[0-9]{2}/
end

#endSegmentGroup(name) ⇒ Object



36
37
38
39
40
41
42
43
44
45
# File 'lib/edifact_converter/edi2xml11/segment_group_handler.rb', line 36

def endSegmentGroup(name)
	if name == 'BrevIndhold'
		self.indhold = false
		open_groups.reject! do |group_name|
			endSegmentGroup group_name
			true
		end
	end
	super
end

#open_groupsObject



11
12
13
# File 'lib/edifact_converter/edi2xml11/segment_group_handler.rb', line 11

def open_groups
	@open_groups ||= []
end

#startSegment(name) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
# File 'lib/edifact_converter/edi2xml11/segment_group_handler.rb', line 20

def startSegment(name)
	if indhold? && name =~ /S[0-9]{2}/
		if open_groups.last
			endSegmentGroup(open_groups.pop)
		end
		open_groups.push name
		startSegmentGroup name, false
	else
		super
	end
end

#startSegmentGroup(name, hidden = false) ⇒ Object



15
16
17
18
# File 'lib/edifact_converter/edi2xml11/segment_group_handler.rb', line 15

def startSegmentGroup(name, hidden = false)
	super
	self.indhold = (name == 'BrevIndhold') unless indhold?
end