From: Logan Capaldo Date: 2006-01-18T06:59:04+09:00 Subject: Re: basic question about Fixnum & Integer On Jan 17, 2006, at 4:44 PM, Guillaume Marcais wrote: > Is it true that RubyGems requires mathn? It seems so to me: > > gus@guslaptop ~]ruby -e 'p(5.lcm(3))' > -e:1: undefined method `lcm' for 5:Fixnum (NoMethodError) > gus@guslaptop ~]ruby -rubygems -e 'p(5.lcm(3))' > 15 > gus@guslaptop ~]ruby -v > ruby 1.8.4 (2005-12-24) [i686-linux] > gus@guslaptop ~]gem -v > 0.8.11 > > > That gives me somewhat of an uneasy feeling. How many core > tampering libraries does RubyGems requires that may make me rely on > methods which are not really in the core? > > Guillaume. > > Tom Allison wrote: >> Jules wrote: >>> No, you don't have to require integer, because it is in the core. >>> The core is always available. You can read the docs here: >>> >>> http://www.ruby-doc.org/core/ >>> >>> And there is a standard library too: >>> >>> http://www.ruby-doc.org/stdlib/ >>> >>> Most of these are not available by default. If you want to use a >>> YAML parser, you have to require YAML. >>> >> Thanks for the references. >> For some reason I can't get my installation of Ruby to do what the >> examples show: >> 6.lcm 7 >> return >> >> 6.lcm 7 >> NoMethodError: undefined method `lcm' for 6:Fixnum >> from (irb):17 >> from :0 >> >> 6.lcm(7) >> NoMethodError: undefined method `lcm' for 6:Fixnum >> from (irb):18 >> from :0 >> This is too simple to get wrong? > > It doesn't require mathn, it requires rational.rb irb(main):013:0> 1/2 => 0 irb(main):014:0> require 'rubygems' => true irb(main):015:0> 1/2 => 0 irb(main):016:0> exit logan:/Users/logan% ruby -e 'p(5.lcm(3))' -e:1: undefined method `lcm' for 5:Fixnum (NoMethodError) logan:/Users/logan% ruby -rubygems -e 'p(5.lcm(3))' 15 logan:/Users/logan% ruby -v ruby 1.8.2 (2004-12-25) [powerpc-darwin8.0] logan:/Users/logan% gem -v 0.8.10 irb(main):001:0> old_features = $LOADED_FEATURES.dup => ["irb.rb", "e2mmap.rb", "irb/init.rb", "irb/context.rb", "irb/ workspace.rb", "irb/extend-command.rb", "irb/ruby-lex.rb", "irb/ slex.rb", "irb/ruby-token.rb", "irb/input-method.rb", "readline.bundle", "irb/locale.rb", "tempfile.rb", "delegate.rb", "tmpdir.rb", "irb/completion.rb"] irb(main):002:0> require 'ubygems' => true irb(main):003:0> new_features = $LOADED_FEATURES - old_features => ["ubygems.rb", "rubygems.rb", "rbconfig.rb", "rubygems/ rubygems_version.rb", "rubygems/source_index.rb", "rubygems/ user_interaction.rb", "forwardable.rb", "rubygems/specification.rb", "date.rb", "rational.rb", "date/format.rb", "rubygems/version.rb", "rubygems/custom_require.rb"]