--------------AA250E39030A1F17F9CC40D6
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

Yukihiro Matsumoto wrote:

> Hi,
>
> In message "[ruby-talk:15828] subclassing Date"
>     on 01/05/28, Michael Husmann <Michael.Husmann / teleatlas.com> writes:
>
> |Using ruby 1.6.0 and trying to subclass the Date class like
> |this:
> |
> |class My_date < Date
> |    def initialize(st)
> |        l  plit(".")
> |        y, m, d  .collect{|s| s.to_i}
> |        super(y,m,d)
> |    end
> |end
> |
> |ruby throws the following error messages when invoking:
> |d  y_date.new("2001.5.28")
> |
> |/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:139:in `exist3?'
> |/usr/local/lib/ruby/1.6/date.rb:147:in `new3'
>
> You're calling `super("2001.5.28",...)'.  I think there's something
> wrong before calling super.  Try:
>
>    class My_date < Date
>        def initialize(st)
>            l  t.split(".")    # note "st."
>            y, m, d  .collect{|s| s.to_i}
>            super(y,m,d)
>        end
>    end
>
>                                                         matz.

Hi Matz,

yes I have forgotten the st before split. But the problem still exists
after changing the code

Michael

--
Michael Husmann
p.A. Tele Atlas Deutschland GmbH, Am neuen Horizont 1, 31177 Harsum
PHONE: +(49) 5127 408-487, FAX: +(49) 5127 408-481
e-mail: Michael.Husmann / teleatlas.com



--------------AA250E39030A1F17F9CC40D6
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: 7bit

<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
Yukihiro Matsumoto wrote:
<blockquote TYPEE>Hi,
<p>In message "[ruby-talk:15828] subclassing Date"
<br>&nbsp;&nbsp;&nbsp; on 01/05/28, Michael Husmann &lt;Michael.Husmann / teleatlas.com>
writes:
<p>|Using ruby 1.6.0 and trying to subclass the Date class like
<br>|this:
<br>|
<br>|class My_date &lt; Date
<br>|&nbsp;&nbsp;&nbsp; def initialize(st)
<br>|&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; l  plit(".")
<br>|&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; y, m, d  .collect{|s|
s.to_i}
<br>|&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; super(y,m,d)
<br>|&nbsp;&nbsp;&nbsp; end
<br>|end
<br>|
<br>|ruby throws the following error messages when invoking:
<br>|d  y_date.new("2001.5.28")
<br>|
<br>|/usr/local/lib/ruby/1.6/date.rb:33:in `civil_to_jd':
<br>|undefined method `-' for "2001.5.28":String (NameError)
<br>|/usr/local/lib/ruby/1.6/date.rb:139:in `exist3?'
<br>|/usr/local/lib/ruby/1.6/date.rb:147:in `new3'
<p>You're calling `super("2001.5.28",...)'.&nbsp; I think there's something
<br>wrong before calling super.&nbsp; Try:
<p>&nbsp;&nbsp; class My_date &lt; Date
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; def initialize(st)
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; l  t.split(".")&nbsp;&nbsp;&nbsp;
# note "st."
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; y, m,
d  .collect{|s| s.to_i}
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; super(y,m,d)
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; end
<br>&nbsp;&nbsp; end
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
matz.</blockquote>
Hi Matz,
<p>yes I have forgotten the st before split. But the problem still exists
after changing the code
<p>Michael
<pre>--
Michael Husmann
p.A. Tele Atlas Deutschland GmbH, Am neuen Horizont 1, 31177 Harsum
PHONE: +(49) 5127 408-487, FAX: +(49) 5127 408-481
e-mail: Michael.Husmann / teleatlas.com</pre>
&nbsp;</html>

--------------AA250E39030A1F17F9CC40D6--