On 2/8/06, charlie bowman <cbowmanschool / yahoo.com> wrote:
> I Generally agree with you but there are certain circumstances where you
> would like to add a "specific to your app" method to a general class.  I
> like to put these at the bottom of a script (which is what I do in
> perl).  If you were going to add a single "specific" method to a
> "general" class would you create a whole new class for this one method
> our would you put it at the top of your script?

Third option: I'd put it into an extension module, than have the
instance extend that module:

  galadriel:~$ cat > foo.rb
    class Foo
      def bar
        puts "bar"
      end
    end

  galadriel:~$ cat > baz.rb
    module Baz
      def baz
        puts "baz"
      end
    end

  galadriel:~$ cat > test.rb
    require 'foo'
    require 'baz'

    foo = Foo.new
    foo.extend Baz
    foo.bar
    foo.baz

  galadriel:~$ ruby test.rb
  bar
  baz

Jacob Fugal