Class: EdifactConverter::XML112EDI::EdiHandler
- Inherits:
-
EmptyHandler
- Object
- EmptyHandler
- EdifactConverter::XML112EDI::EdiHandler
- Defined in:
- lib/edifact_converter/xml112edi/edi_handler.rb
Instance Attribute Summary collapse
-
#binary ⇒ Object
Returns the value of attribute binary.
-
#edifact ⇒ Object
Returns the value of attribute edifact.
-
#first_value ⇒ Object
(also: #first_value?)
Returns the value of attribute first_value.
-
#linebreak ⇒ Object
Returns the value of attribute linebreak.
-
#processing_binary ⇒ Object
(also: #processing_binary?)
Returns the value of attribute processing_binary.
Attributes inherited from EmptyHandler
Instance Method Summary collapse
- #binary? ⇒ Boolean
- #endSegment ⇒ Object
-
#initialize(nexthandler = nil) ⇒ EdiHandler
constructor
A new instance of EdiHandler.
- #startDocument ⇒ Object
- #startElement ⇒ Object
- #startSegment(name, position = nil) ⇒ Object
- #value(text) ⇒ Object
Methods inherited from EmptyHandler
Constructor Details
#initialize(nexthandler = nil) ⇒ EdiHandler
Returns a new instance of EdiHandler.
22 23 24 25 |
# File 'lib/edifact_converter/xml112edi/edi_handler.rb', line 22 def initialize(nexthandler = nil) self.linebreak = "\n" if EdifactConverter::Configuration.format_edi super end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class EdifactConverter::EmptyHandler
Instance Attribute Details
#binary ⇒ Object
Returns the value of attribute binary.
9 10 11 |
# File 'lib/edifact_converter/xml112edi/edi_handler.rb', line 9 def binary @binary end |
#edifact ⇒ Object
Returns the value of attribute edifact.
9 10 11 |
# File 'lib/edifact_converter/xml112edi/edi_handler.rb', line 9 def edifact @edifact end |
#first_value ⇒ Object Also known as: first_value?
Returns the value of attribute first_value.
9 10 11 |
# File 'lib/edifact_converter/xml112edi/edi_handler.rb', line 9 def first_value @first_value end |
#linebreak ⇒ Object
Returns the value of attribute linebreak.
9 10 11 |
# File 'lib/edifact_converter/xml112edi/edi_handler.rb', line 9 def linebreak @linebreak end |
#processing_binary ⇒ Object Also known as: processing_binary?
Returns the value of attribute processing_binary.
9 10 11 |
# File 'lib/edifact_converter/xml112edi/edi_handler.rb', line 9 def processing_binary @processing_binary end |
Instance Method Details
#binary? ⇒ Boolean
69 70 71 |
# File 'lib/edifact_converter/xml112edi/edi_handler.rb', line 69 def binary? binary.any? end |
#endSegment ⇒ Object
61 62 63 64 65 66 67 |
# File 'lib/edifact_converter/xml112edi/edi_handler.rb', line 61 def endSegment if processing_binary? self.processing_binary = false else edifact.write("'#{linebreak}") end end |
#startDocument ⇒ Object
27 28 29 30 31 |
# File 'lib/edifact_converter/xml112edi/edi_handler.rb', line 27 def startDocument self.edifact = nil binary.clear edifact.write("UNA:+.? '#{linebreak}") end |
#startElement ⇒ Object
41 42 43 44 45 46 |
# File 'lib/edifact_converter/xml112edi/edi_handler.rb', line 41 def startElement unless processing_binary? edifact.write('+') self.first_value = true end end |
#startSegment(name, position = nil) ⇒ Object
33 34 35 36 37 38 39 |
# File 'lib/edifact_converter/xml112edi/edi_handler.rb', line 33 def startSegment(name, position = nil) if name == "OBJ" self.processing_binary = true else edifact.write(name) end end |
#value(text) ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/edifact_converter/xml112edi/edi_handler.rb', line 48 def value(text) if processing_binary? id = binary_id binary[id] = text text = id elsif first_value self.first_value = false else edifact.write(':') unless first_value? end edifact.write text.to_s.gsub(/([\?:\'\+])/,'?\1') end |