Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In irb, how do I 'require a library'

Tags:

ruby

I'm following a book called the "Beginner's Guide to Ruby" and I'm afraid I'm not sure what 'requiring a library' means.

In my applications root directory I have a file called wordplay.rb and a I know how to start irb in Terminal. But I don't know how to

'use irb and require in the wordplay library'

like image 403
Starkers Avatar asked May 17 '13 00:05

Starkers


1 Answers

From the directory wordplay.rb is in, run irb and enter:

irb(main):001:0> require './wordplay'

Hopefully it will come back saying:

=> true

which means that the file was loaded successfully.

If it doesn't say 'true', it means that you still have to install a Ruby Gem which provides the library. To install a gem, you have to type this in your shell:

 gem install wordplay     # or whatever your gem is called
like image 173
Lucas Jones Avatar answered Sep 28 '22 02:09

Lucas Jones