On Apr 6, 2:50 pm, Phillip Gawlowski <cmdjackr... / googlemail.com>
wrote:
> John J. Franey wrote:
> > Brian,
>
> > Thanks for responding:
>
> > This code:
>
> > require 'rubygems'
> > require 'netaddr'
> > ipadd = NetAddr::CIDR.create("192.9.200.0/24")
>
> > gives:
>
> > /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in
> > `gem_original_require': no such file to load -- netaddr (LoadError)
> >         from /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in
> > `require'
> >         from ci.rb:2
>
> > This code:
>
> > require 'rubygems'
> > require 'net_addr'
> > ipadd = NetAddr::CIDR.create("192.9.200.0/24")
>
> > works.
>
> > Now, how am I supposed to learn the right string to put into the require
> > call.  The command to install was:
>
> > gem install netaddr
>
> If the gem generates documentation, I'd look there. Otherwise, look into
> your /usr/lib/ruby/gems/1.8/name_of_gem directories for a README or code
> code examples. In case you didn't know it gem_server launches a small
> server, which makes the RDoc documentation accessible (in case the
> developer was smart enough to include such a thing ;)
>
> Otherwise, you might take your chances and even look at the gem's
> homepage. in this case, it probably ishttp://netaddr.rubyforge.org
>
> P.S.:
> A: Because it makes reading replies difficult.
> Q: Why is top-posting bad?
>
> --
> Phillip "CynicalRyan" Gawlowskihttp://cynicalryan.110mb.com/
>
> Rule of Open-Source Programming #1:
>
> Don't whine unless you are going to implement it yourself.- Hide quoted text -
>
> - Show quoted text -

I got caught in the same puzzle that the OP got trapped.

A gem has a name "gemname" which is used to install  --- gem install
gemname
A "require"  loads the gem and needs to know the gem's base
filename .. which is the filename without an extension.
Usually (probably 99% of time), the gemname and the base filename are
the same although it is not a requirement.
A gem filename may have "rb" as an extension but it could also have
"so" as an extension ... 'require' is smart enough to look
for valid extensions.

As CynicalRyan stated, you have to dig into the documentation and hope
to find the information.

In the case of the netaddr gem, the example in the documentation is
outdated. Only by looking at the list of netaddr's files would you
have seen "net_addr.rb"