class EdifactConverter::Converter

Attributes

error_proc[RW]

Public Instance Methods

convert(text, &proc) click to toggle source
# File lib/edifact_converter/converter.rb, line 9
def convert(text, &proc)
  self.error_proc = proc || Proc.new { |msg| STDERR.puts msg }
  xml = Nokogiri::XML(text)
  if xml.errors.empty?
    convert_xml(xml)
  else
    convert_edifact(text)
  end
end

Private Instance Methods

convert_edifact(text) click to toggle source
# File lib/edifact_converter/converter.rb, line 23
def convert_edifact(text)
  handler = EdifactConverter::EDI2XML11::XmlHandler.new
  reader = EdifactConverter::EDI2XML11::EdiReader.new handler
  reader.parse_string text, properties
  puts handler.xml
end
convert_xml(xml) click to toggle source
# File lib/edifact_converter/converter.rb, line 30
def convert_xml(xml)

end
properties() click to toggle source
# File lib/edifact_converter/converter.rb, line 34
def properties
  @properties ||= Hash.new do |hash,key|
    case key
    when :errors
      hash[key] = []
    when :warnings
      hash[key] = []
    else
      nil
    end
  end
end