Class: X12edi::Base

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

Direct Known Subclasses

EightThirtyFive

Instance Method Summary collapse

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

#parserObject



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