0

I'm using the hippo gem to parse X12 files into their segments and values. I am using the parser method and I expected it to return variables of the class: Hippo::TransactionSets::Hippa_837::Base but the value returned is of class Array. Within the library I can put the quantity I need into a global variable and access it that way but I don't think I should have to do that. I tried to create a variable of the class and set its value with the parser method return, so far no luck with that.

begin  
require 'rubygems'
gem 'minitest'
require 'minitest/autorun'
require 'pp'
require 'pry'
require 'hippo'

t = Hippo::Parser.parse_string(File.read('c:/test.edi'))
puts "DONE: "
puts t.class
puts $t.class
gets
puts $t.ST
end   

The output:

DONE: 
Hippo::TransactionSets::HIPAA_837::Base
Array
ST*837*0021*005010X222A1~

$t is the global variable I set in the parser.rb lib file. t turns out to be an array class without the methods to access segments.

  • 2
    Could you post a code example illustrating this? – Daniel Szmulewicz Oct 02 '12 at 01:05
  • Ruby:begin require 'rubygems' gem 'minitest' require 'minitest/autorun' require 'pp' require 'pry' require 'hippo' t = Hippo::Parser.parse_string(File.read('c:/test.edi')) puts "DONE: " puts t.class puts $t.class gets puts $t.ST end – user1137656 Oct 02 '12 at 17:23
  • That did not work, I will try to edit the post with the source and output. Thanks – user1137656 Oct 02 '12 at 17:25
  • That's better, it seem to me that the variable t should be the hippo class so that one can access segments via its methods. – user1137656 Oct 02 '12 at 17:34

1 Answers1

0

You need to iterate over the array, or fetch individual elements, and then you will find the objects you expect, with all the methods associated to segments.

Daniel Szmulewicz
  • 3,971
  • 2
  • 25
  • 26