Class: EdifactConverter::Edifact
- Inherits:
-
Object
- Object
- EdifactConverter::Edifact
- Defined in:
- lib/edifact_converter/edifact.rb
Defined Under Namespace
Classes: DummyElement
Constant Summary collapse
- ATTRIBUTES =
[:ast, :text]
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Edifact
constructor
A new instance of Edifact.
- #parse(options = {}, &block) ⇒ Object
- #serialize(options = {}, &block) ⇒ Object
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( = {}) .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( = {}, &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( = {}, &block) end |