[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Weird Gem Error

bcparanj@gmail.com

7/5/2007 7:06:00 PM

I installed the Facets gem on Mac OS using sudo gem install command.
In the irb session I get the following error:

irb(main):002:0> [1,2].shuffle
NoMethodError: undefined method `shuffle' for [1, 2]:Array
from (irb):2

I also ran the setup.rb of the Facets library with no luck. How do I
get the Facets library working? TIA.

3 Answers

Chris Shea

7/5/2007 7:50:00 PM

0

On Jul 5, 1:05 pm, "bcpar...@gmail.com" <bcpar...@gmail.com> wrote:
> I installed the Facets gem on Mac OS using sudo gem install command.
> In the irb session I get the following error:
>
> irb(main):002:0> [1,2].shuffle
> NoMethodError: undefined method `shuffle' for [1, 2]:Array
> from (irb):2
>
> I also ran the setup.rb of the Facets library with no luck. How do I
> get the Facets library working? TIA.

You need to require the gem (or, in the case of Facets, at least the
part you want). So,

irb(main):001:0> [1,2].shuffle
NoMethodError: undefined method `shuffle' for [1, 2]:Array
from (irb):1
irb(main):002:0> require 'facet/array/shuffle'
=> true
irb(main):003:0> [1,2].shuffle
=> [2, 1]

If you don't have "require 'rubygems'" in your .irbrc, then you'll
need to do that first.

See the Usage section of the README here: http://facets.rubyforge.org/src/doc/rdoc/core/...

See the "Using a gem in your code" section of the Rubygems manual
here: http://rubygems.org/read/chapte...

HTH,
Chris

bcparanj@gmail.com

7/5/2007 8:44:00 PM

0

Thanks Chris. It works if I do require 'facet/array/shuffle' but it
does not if I just do require 'facets'. According to the Readme in
facets that should also work. Any idea why it doesn't work?

> See the Usage section of the README here:http://facets.rubyforge.org/src/doc/rdoc/core/...
>
> See the "Using a gem in your code" section of the Rubygems manual
> here:http://rubygems.org/read/chapte...
>
> HTH,
> Chris


Chris Shea

7/5/2007 9:03:00 PM

0

On Jul 5, 2:43 pm, "bcpar...@gmail.com" <bcpar...@gmail.com> wrote:
> Thanks Chris. It works if I do require 'facet/array/shuffle' but it
> does not if I just do require 'facets'. According to the Readme in
> facets that should also work. Any idea why it doesn't work?

It doesn't work because it's not supposed to.

Quoting from the readme in regards to "require 'facets': "This loads a
set of facets considered 'BASE' -currently a couple dozen very basic
methods, and adds the facets library directories to the end of Ruby's
load path. This allows you to require facets without even using the
'facet/...' prefix."

At that point you then must require 'array/shuffle'.

Chris