Using the ice_cube Ruby pearl in IRB

I am trying to use a Ruby gem called ice_cube in IRB, but it does not work:

[~]$ 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>' 

What am I doing wrong? (I am a beginner Ruby programmer.)

+6
source share
3 answers

It should be:

 schedule = IceCube::Schedule.new(Time.now) 
+16
source
 include IceCube schedule = Schedule.new(Time.now) 

Or you can first include the module in the global namespace, then you can use everything that is in this module.

+3
source

You had a similar problem, try restarting the Rails application.

0
source

Source: https://habr.com/ru/post/920726/


All Articles