On Sat, 19 Feb 2005 06:54:49 +0900, Panagiotis Karvounis
<pkarvou / gmail.com> wrote:
> Hi,I have just started using this great programming language and I am
> testing some features that I use with java.I am testing modules now.
> 
> You may find my question very easy, but I hope you can help.
> 
> When I run tmp.rb I get the error; "tmp.rb:3: uninitialized constant
> Pdate (NameError)"
> 
> Why?
> 

You need to give the module name before the class:

a = MyTools::Pdate.new(25,8,1983)
b = MyTools::Pdate.new(26,5,1986)

You can also 'include Comparable' in you class to make comparisons
easier.  Here's a stripped down version of your code - with minor
edits just to show you 'case' and 'puts'.

module MyTools

  class Pdate
    include Comparable

  	attr_reader :day , :month , :year

  	def initialize(day,month,year)
  		@day=day
  		@month=month
  		@year=year
  	end


    def <=> (other)
      (@year <=> other.year) and (@month <=> other.month) and (@day
<=> other.day)
    end
  end

end

a = MyTools::Pdate.new(25,8,1986)
b = MyTools::Pdate.new(25,8,1986)

case
  when a < b then puts "I am older"
  when a > b then puts "I am younger"
  else            puts "We are the same age"
end

-- 
Bill Guindon (aka aGorilla)