Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

class:Record does not compile, undefined method error #1

Open
cclose opened this issue Feb 13, 2013 · 4 comments
Open

class:Record does not compile, undefined method error #1

cclose opened this issue Feb 13, 2013 · 4 comments

Comments

@cclose
Copy link

cclose commented Feb 13, 2013

I downloaded your gem ruby-adt 0.5.0 for use with ruby 1.9.3 and tried to use, but I receive a compile error "undefined method 'delegate'".

I'm not even trying to use it yet, i've simply added "require 'adt'" to the top of my (otherwise empty) file. The exact error received is:

ruby readAdt.rb
/home/xes/.rvm/gems/ruby-1.9.3-p385/gems/ruby-adt-0.5.0/lib/adt/record.rb:8:in <class:Record>': undefined methoddelegate' for ADT::Record:Class (NoMethodError)
from /home/xes/.rvm/gems/ruby-1.9.3-p385/gems/ruby-adt-0.5.0/lib/adt/record.rb:5:in <module:ADT>' from /home/xes/.rvm/gems/ruby-1.9.3-p385/gems/ruby-adt-0.5.0/lib/adt/record.rb:3:in<top (required)>'
from /home/xes/.rvm/rubies/ruby-1.9.3-p385/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in require' from /home/xes/.rvm/rubies/ruby-1.9.3-p385/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:inrequire'
from /home/xes/.rvm/gems/ruby-1.9.3-p385/gems/ruby-adt-0.5.0/lib/adt.rb:18:in <top (required)>' from /home/xes/.rvm/rubies/ruby-1.9.3-p385/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:60:inrequire'
from /home/xes/.rvm/rubies/ruby-1.9.3-p385/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:60:in rescue in require' from /home/xes/.rvm/rubies/ruby-1.9.3-p385/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:35:inrequire'
from readAdt.rb:4:in `

'

Full source code is:

!/usr/bin/ruby

require 'rubygems'
require 'adt'

table = ADT::Table.new("messageinfo.adt")

table.each do |record|

    #puts record.id

end

puts "It worked!"

This is fresh install of ruby 1.9.3, using the rvm. The only gem i've installed is mysql2 and ruby-adt

@ghost
Copy link

ghost commented Apr 8, 2013

Hey @cclose, I ran into a similar problem, I was trying to use this gem with ruby-2.0 under Linux. A friend of mine recommended using an earlier version of Ruby (I see you're on 1.9.1), I ran it under OS X (10.6.8 ruby-1.8.3) and it runs OK. Something very strange, I'm a ruby noob but my code only seems to work properly with irb (vs /usr/bin/ruby). If it's running against /usr/bin/ruby it says it can't find adt ... probably a path issue. shrug

I see @chasemgray posted some schematics on his website regarding the file format, I would like to create a Python or Perl package to deal with these files but I don't have much free time or skills ... but maybe someday.

Anyways, good luck!

@chasemgray
Copy link
Owner

I haven't really kept up with this gem. I will try to take a look though and make sure it at least works with the latest version of Ruby.

@ghost
Copy link

ghost commented Apr 14, 2013

Hi Chase,

Thanks for contacting me,

That would be great if you have the time to work on that, I think I'll
still try my hand at writing a Python or Perl module for ADT files (better
for my situation). Thanks again for writing this, I have an old
healthcare-related app I'm trying to extract some data from and it seems
like a handy way to do it.

Take care, and I really enjoyed reading your blog (after grimacing a bit).

John

On 13 April 2013 22:04, Chase Gray [email protected] wrote:

I haven't really kept up with this gem. I will try to take a look though
and make sure it at least works with the latest version of Ruby.


Reply to this email directly or view it on GitHubhttps://github.com//issues/1#issuecomment-16345626
.

@ntbob
Copy link

ntbob commented Apr 21, 2013

I have a workaround that will allow this gem to be used with Ruby 1.9.3 on Windows. Haven't tried it on OSX or Linux so your mileage may vary. But here's what I had to do...

In the "record.rb" file included with the ruby-adt gem, after the module declaration add

require 'forwardable'

Then, inside the Record class add

extend Forwardable

Then change the line "delegate :columns, :to => :@table" to the following

def_delegators :@table, :columns

That should do it. If, after making these changes, you get a method undefined error for the underscore method, add the following after your "require 'forwardable'" statement (obviously, you'll have to install activesupport if you don't already have it).

require 'active_support/core_ext/string/inflections'

Hope this helps. Let me know how it works for you. Now if I could just figure out how to correctly unpack advantage date fields with this gem, I'll be set.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants