我有以下文件结构:
> execute.rb
> lib
> my_class.rb
在execute.rb中,我有以下代码:
#!/usr/bin/ruby require 'lib/my_class' my_object= MyClass.new my_object.some_method
这是my_class.rb的代码:
class MyClass def some_method puts 'OK' end end
所以,我尝试运行execute.rb:
ruby execute.rb
但我收到这个错误:
/home/vagrant/.rvm/rubies/ruby-2.0.0-p195/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:45:in `require': cannot load such file -- lib/my_class (LoadError) from /home/vagrant/.rvm/rubies/ruby-2.0.0-p195/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:45:in `require' from execute.rb:3:in `<main>'
谁能帮我?我会感激任何帮助.
非常感谢.