Irb (with irbtools) problem including a module

Hi all -
I’m using irb with irbtools enabled on an iMac. I find this strange:
if I inline a module (put it at the beginning of a program) everything
works fine. If I try to include the module, it fails. The module is in a
file with the same name (.rb) in the same directory I’m working in.

I have an employee class that includes a subject module. If I do it this
way (as separate .rb files) I get this error:
require ‘employee’
NameError: uninitialized constant Employee::Subject
from /Users/david/Ruby/employee.rb:2:in <class:Employee>' from /Users/david/Ruby/employee.rb:1:in<top (required)>’
from
/Users/david/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in
require' from /Users/david/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:inrequire’
from (irb):2
from /Users/davidmazzoni/.rvm/rubies/ruby-1.9.2-p290/bin/irb:16:in
`’

Thanks for any suggestions -
Dave

Hi all -
I’m using irb with irbtools enabled on an iMac. I find this strange:
if I inline a module (put it at the beginning of a program) everything
works fine. If I try to include the module, it fails. The module is in a
file with the same name (.rb) in the same directory I’m working in.

I’ve attached employee.rb and subject.rb

I found the solution. Duh! I wasn’t “requiring” the file before I
“included” it – brain damage from C/C++.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs