Class: EdifactConverter::EDI2XML11::EdiReader
- Inherits:
-
Object
- Object
- EdifactConverter::EDI2XML11::EdiReader
- Defined in:
- lib/edifact_converter/edi2xml11/edi_reader.rb
Instance Attribute Summary collapse
-
#edifile ⇒ Object
Returns the value of attribute edifile.
-
#handler ⇒ Object
Returns the value of attribute handler.
-
#locator ⇒ Object
Returns the value of attribute locator.
Instance Method Summary collapse
-
#initialize(handler = Pipeline.handler) ⇒ EdiReader
constructor
A new instance of EdiReader.
- #parse(edifile, properties, close = false) ⇒ Object
- #parse_string(edistring, properties) ⇒ Object
Constructor Details
Instance Attribute Details
#edifile ⇒ Object
Returns the value of attribute edifile.
6 7 8 |
# File 'lib/edifact_converter/edi2xml11/edi_reader.rb', line 6 def edifile @edifile end |
#handler ⇒ Object
Returns the value of attribute handler.
6 7 8 |
# File 'lib/edifact_converter/edi2xml11/edi_reader.rb', line 6 def handler @handler end |
#locator ⇒ Object
Returns the value of attribute locator.
6 7 8 |
# File 'lib/edifact_converter/edi2xml11/edi_reader.rb', line 6 def locator @locator end |
Instance Method Details
#parse(edifile, properties, close = false) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/edifact_converter/edi2xml11/edi_reader.rb', line 18 def parse(edifile, properties, close = false) locator.properties = properties if edifile.kind_of? String close = true self.edifile = PositionIO.new (File.open edifile, 'rb', encoding: 'ISO-8859-1') else self.edifile = PositionIO.new edifile end handler.startDocument begin eatCrap parseUNA eatCrap while(parseSegment) eatCrap end rescue EOFError handler.endDocument end self.edifile.close if close handler.xml end |
#parse_string(edistring, properties) ⇒ Object
14 15 16 |
# File 'lib/edifact_converter/edi2xml11/edi_reader.rb', line 14 def parse_string(edistring, properties) parse StringIO.new(edistring), properties end |