"NAKAMURA, Hiroshi" wrote:

> Hi,
>
> I'm sorry for replying matz' article.  I've lost the
> original post.
>
> > |class My_date < Date
> > |    def initialize(st)
> > |        l = split(".")
> > |        y, m, d = l.collect{|s| s.to_i}
> > |        super(y,m,d)
> > |    end
> > |end
>
> Date.new is aliased to Date.new3 and Date.new0 is aliased
> to Date.new in date.rb.  Maybe following definition works
> but it might not be intuitive...
>
> class My_date < Date
>   def new3(st)
>     ...
>   end
> end
>
> // NaHi

Hi NaHi,

sorry for ommitting the st variable in my first posting.

Thank you for your reply.  I changed the code following your
proposal:

#!/usr/bin/env ruby -w

require "date"


class My_date < Date
    def new3(st)
        l = st.split(".")
        y, m, d = l.collect{|s| s.to_i}
        printf("year: %d, month: %d, day: %d\n", y, m, d)
        super(y,m,d)
    end
end

st = "2001.5.28"
d = My_date.new(st)

ruby still throws that error messages:
/usr/local/lib/ruby/1.6/date.rb:33:in `civil_to_jd':
undefined method `-' for "2001.5.28":String (NameError)
/usr/local/lib/ruby/1.6/date.rb:137:in `exist3?'
/usr/local/lib/ruby/1.6/date.rb:146:in `new3'
...

Is that a bug in ruby? Or a bug in that lib?
I don't think so, because I am absolutely new to ruby. So I
think there is a bug in my code, but I have no idea what's
wrong with it.

Could you look at it again? Thank you,

Michael