diff options
author | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 1999-02-16 03:42:20 +0000 |
---|---|---|
committer | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 1999-02-16 03:42:20 +0000 |
commit | ec82e48deb8fb294bda58afb5a93b0b69817e305 (patch) | |
tree | 5d8277bfa20f0d9fe102d68bd9211008e8ae446b /lib | |
parent | bcec81835dc263b933f2629aa5329f6c943da60d (diff) |
1.2.3
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/v1_1r@404 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib')
-rw-r--r-- | lib/date2.rb | 24 | ||||
-rw-r--r-- | lib/weakref.rb | 7 |
2 files changed, 15 insertions, 16 deletions
diff --git a/lib/date2.rb b/lib/date2.rb index 50c2ccfbd9..6e87824b38 100644 --- a/lib/date2.rb +++ b/lib/date2.rb @@ -1,11 +1,11 @@ -# date.rb: Written by Tadayoshi Funaba 1998 -# $Id: date.rb,v 1.4 1998/06/01 12:52:33 tadf Exp $ +# date.rb: Written by Tadayoshi Funaba 1998, 1999 +# $Id: date.rb,v 1.5 1999/02/06 08:51:56 tadf Exp $ class Date include Comparable - MONTHNAMES = [ '', 'January', 'February', 'March', 'April', 'May', 'June', + MONTHNAMES = [ nil, 'January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December' ] DAYNAMES = [ 'Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', @@ -162,26 +162,24 @@ class Date end def + (other) - if other.kind_of? Numeric then - return Date.new(@jd + other, @gs) + case other + when Numeric; return Date.new(@jd + other, @gs) end fail TypeError, 'expected numeric' end def - (other) - if other.kind_of? Numeric then - return Date.new(@jd - other, @gs) - elsif other.kind_of? Date then - return @jd - other.jd + case other + when Numeric; return Date.new(@jd - other, @gs) + when Date; return @jd - other.jd end fail TypeError, 'expected numeric or date' end def <=> (other) - if other.kind_of? Numeric then - return @jd <=> other - elsif other.kind_of? Date then - return @jd <=> other.jd + case other + when Numeric; return @jd <=> other + when Date; return @jd <=> other.jd end fail TypeError, 'expected numeric or date' end diff --git a/lib/weakref.rb b/lib/weakref.rb index c31e959e74..d53aa15c71 100644 --- a/lib/weakref.rb +++ b/lib/weakref.rb @@ -60,10 +60,11 @@ class WeakRef<Delegator end if __FILE__ == $0 + require 'thread' foo = Object.new - p foo.hash # original's hash value + p foo.to_s # original's class foo = WeakRef.new(foo) - p foo.hash # should be same hash value + p foo.to_s # should be same class ObjectSpace.garbage_collect - p foo.hash # should raise exception (recycled) + p foo.to_s # should raise exception (recycled) end |