Class: EdifactConverter::Edifact

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

Defined Under Namespace

Classes: DummyElement

Constant Summary collapse

ATTRIBUTES =
[:ast, :text]

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Edifact

Returns a new instance of Edifact.



17
18
19
20
21
22
23
24
25
# File 'lib/edifact_converter/edifact.rb', line 17

def initialize(options = {})
  options.each do |name, value|
    if ATTRIBUTES.include? name
      send "#{name}=", value
    else
      raise ArgumentError, 'Argument(#{name}) is not supported '
    end
  end
end

Instance Method Details

#parse(options = {}, &block) ⇒ Object



27
28
29
30
31
32
33
34
35
# File 'lib/edifact_converter/edifact.rb', line 27

def parse(options = {}, &block)
  return ast unless text
  handler = EdifactConverter::EDI2XML11::XmlHandler.new
  reader = EdifactConverter::EDI2XML11::EdiReader.new handler
  reader.parse_string text, properties
  xml = handler.xml
  insert_letters xml
  self.ast = AbstractSyntaxTree.new xml
end

#serialize(options = {}, &block) ⇒ Object



37
38
39
# File 'lib/edifact_converter/edifact.rb', line 37

def serialize(options = {}, &block)

end