class X12edi::Base

Public Class Methods

new(data) click to toggle source
# File lib/x12edi.rb, line 6
def initialize(data)
  @data = data
end

Public Instance Methods

el(m, *ns) { |*map{|n| element(*n).map(&:node).map(&:value).fetch(nil) }| ... } click to toggle source
# 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() click to toggle source
# 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