Class: EdifactConverter::XML112EDI::ChecksumHandler

Inherits:
EmptyHandler
  • Object
show all
Defined in:
lib/edifact_converter/xml112edi/checksum_handler.rb

Instance Attribute Summary collapse

Attributes inherited from EmptyHandler

#locator, #next_handler

Instance Method Summary collapse

Methods inherited from 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

#inside_UNTObject

Returns the value of attribute inside_UNT.



7
8
9
# File 'lib/edifact_converter/xml112edi/checksum_handler.rb', line 7

def inside_UNT
  @inside_UNT
end

#inside_UNZObject

Returns the value of attribute inside_UNZ.



7
8
9
# File 'lib/edifact_converter/xml112edi/checksum_handler.rb', line 7

def inside_UNZ
  @inside_UNZ
end

#lettersObject

Returns the value of attribute letters.



7
8
9
# File 'lib/edifact_converter/xml112edi/checksum_handler.rb', line 7

def letters
  @letters
end

#segmentsObject

Returns the value of attribute segments.



7
8
9
# File 'lib/edifact_converter/xml112edi/checksum_handler.rb', line 7

def segments
  @segments
end

Instance Method Details

#startDocumentObject



9
10
11
12
# File 'lib/edifact_converter/xml112edi/checksum_handler.rb', line 9

def startDocument
	self.segments = self.letters = 0
	super
end

#startSegment(name, position = nil) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/edifact_converter/xml112edi/checksum_handler.rb', line 14

def startSegment(name, position = nil)
	case name
	when 'UNH'
		self.letters += 1
		self.segments = 0
	when 'UNT'
		self.inside_UNT = true
	when 'UNZ'
		self.inside_UNZ = true
	end
	self.segments += 1 unless name == 'OBJ'
	super
end

#value(text) ⇒ Object



28
29
30
31
32
33
34
35
36
37
38
# File 'lib/edifact_converter/xml112edi/checksum_handler.rb', line 28

def value(text)
	if inside_UNT
		super(segments) 
	elsif inside_UNZ
		super(letters) 
	else 
		super
	end
	self.inside_UNT = false
	self.inside_UNZ = false
end