Class: X12edi::Base
- Inherits:
-
Object
- Object
- X12edi::Base
- Defined in:
- lib/x12edi.rb
Direct Known Subclasses
Instance Method Summary collapse
- #el(m, *ns, &block) ⇒ Object
-
#initialize(data) ⇒ Base
constructor
A new instance of Base.
- #parser ⇒ Object
Constructor Details
#initialize(data) ⇒ Base
Returns a new instance of Base.
6 7 8 |
# File 'lib/x12edi.rb', line 6 def initialize(data) @data = data end |
Instance Method Details
#el(m, *ns, &block) ⇒ Object
22 23 24 25 26 27 28 |
# File 'lib/x12edi.rb', line 22 def el(m, *ns, &block) if Stupidedi::Either === m m.tap{|m| el(m, *ns, &block) } else yield(*ns.map{|n| m.element(*n).map(&:node).map(&:value).fetch(nil) }) end end |
#parser ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/x12edi.rb', line 10 def parser config = Stupidedi::Config.default parser = Stupidedi::Builder::StateMachine.build(config) parser, result = parser.read(Stupidedi::Reader.build(@data)) if result.fatal? result.explain{|reason| raise reason + " at #{result.position.inspect}" } end parser end |