Class: EdifactConverter::XML112EDI::XmlReader

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeXmlReader

Returns a new instance of XmlReader.



10
11
12
13
# File 'lib/edifact_converter/xml112edi/xml_reader.rb', line 10

def initialize()
  self.edifact = EdiHandler.new
  self.handler = ChecksumHandler.new edifact
end

Instance Attribute Details

#edifactObject

Returns the value of attribute edifact.



8
9
10
# File 'lib/edifact_converter/xml112edi/xml_reader.rb', line 8

def edifact
  @edifact
end

#handlerObject

Returns the value of attribute handler.



8
9
10
# File 'lib/edifact_converter/xml112edi/xml_reader.rb', line 8

def handler
  @handler
end

#stateObject

Returns the value of attribute state.



8
9
10
# File 'lib/edifact_converter/xml112edi/xml_reader.rb', line 8

def state
  @state
end

Instance Method Details

#parse(xmlstr, properties) ⇒ Object



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

def parse(xmlstr, properties)
  xml11 = if xmlstr.is_a? String
    Nokogiri::XML(xmlstr) { |config| config.nonet }
  else
    xmlstr
  end
  xml11.errors.each do |error|
    properties[:errors] << EdifactConverter::Message.from_syntax_error(error)
  end
  parse_xml xml11
end