hi Fily,

  you can think of a module as a collection of useful methods that you
can pass around (mix in) between various classes.  from what i
understand modules have a lot less 'overhead' than classes as well.

  you could write a module called 'Transmission' in which you define how
to shift gears - and then mix that module into different vehicle classes
that will all share the methods defined in the module...

  module Transmission
    attr_reader :gear
    def num_of_gears=(n)
      ...
    end
    def clutch
      ...
    end
    def shift(up_or_down)
      ...
    end
    def grind_gears
      ...
    end
  end

  class Car
    include Transmission
    def initialize(n)
      num_of_gears = (n)
      ...
    end
    ...
  end

  class Motorcycle
    include Transmission
    def initialize(n)
      num_of_gears = (n)
      ...
    end
    ...
  end

  bike = Motorcycle.new(5)
  car = Car.new(4)

  bike.clutch
  bike.shift('up')

  car.clutch
  car.shift('up')

  etc....


  - j

-- 
Posted via http://www.ruby-forum.com/.