Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/selenium/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby 在IRB中使用ice_cube红宝石_Ruby_Gem_Irb_Ice Cube - Fatal编程技术网

Ruby 在IRB中使用ice_cube红宝石

Ruby 在IRB中使用ice_cube红宝石,ruby,gem,irb,ice-cube,Ruby,Gem,Irb,Ice Cube,我尝试使用IRB中的Ruby gem,但它不起作用: [~]$ rvm gemset create ice 'ice' gemset created (/home/joe/.rvm/gems/ruby-1.9.2-p320@ice). [~]$ rvm gemset use ice Using ruby-1.9.2-p320 with gemset ice [~]$ gem install ice_cube Fetching: ice_cube-0.8.0.gem (100%) Succes

我尝试使用IRB中的Ruby gem,但它不起作用:

[~]$ rvm gemset create ice
'ice' gemset created (/home/joe/.rvm/gems/ruby-1.9.2-p320@ice).

[~]$ rvm gemset use ice
Using ruby-1.9.2-p320 with gemset ice

[~]$ gem install ice_cube
Fetching: ice_cube-0.8.0.gem (100%)
Successfully installed ice_cube-0.8.0
1 gem installed
Installing ri documentation for ice_cube-0.8.0...
Installing RDoc documentation for ice_cube-0.8.0...

[~]$ irb --simple-prompt
>> require 'ice_cube'
=> true

>> schedule = Schedule.new(Time.now)
NameError: uninitialized constant Object::Schedule
    from (irb):2
    from /home/joe/.rvm/rubies/ruby-1.9.2-p320/bin/irb:16:in `<main>'
[~]$rvm gemset创建ice
创建了“ice”gemset(/home/joe/.rvm/gems/ruby-1.9.2-p320@ice).
[~]$rvm宝石使用冰
使用ruby-1.9.2-p320和gemset ice
[~]$gem安装冰立方
取数:冰立方-0.8.0.gem(100%)
已成功安装ice_cube-0.8.0
已安装1个gem
正在安装ice_cube-0.8.0的ri文档。。。
正在安装ice_cube-0.8.0的RDoc文档。。。
[~]$irb——简单提示
>>需要“冰块”
=>正确
>>schedule=schedule.new(Time.now)
NameError:未初始化的常量对象::计划
来自(irb):2
from/home/joe/.rvm/rubies/ruby-1.9.2-p320/bin/irb:16:in`'
我做错了什么?(我是一名Ruby初学者。)

应该是:

schedule = IceCube::Schedule.new(Time.now)

或者,您可以首先将模块包含到全局名称空间中,然后使用该模块中的任何内容

遇到类似问题,请尝试重新启动Rails应用程序。

gem的大部分文档都没有明确说明这一点。同意。非常明显的疏忽见下文。。。文件中提到了这一点。
include IceCube
schedule = Schedule.new(Time.now)