ruby-changes:13610
From: tadf <ko1@a...>
Date: Sun, 18 Oct 2009 22:39:10 +0900 (JST)
Subject: [ruby-changes:13610] Ruby:r25393 (trunk): * lib/date.rb: do not require lib/delta.rb.
tadf 2009-10-18 22:38:55 +0900 (Sun, 18 Oct 2009) New Revision: 25393 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=25393 Log: * lib/date.rb: do not require lib/delta.rb. * lib/date/delta.rb: follows the above change. Modified files: trunk/ChangeLog trunk/lib/date/delta.rb trunk/lib/date.rb Index: ChangeLog =================================================================== --- ChangeLog (revision 25392) +++ ChangeLog (revision 25393) @@ -1,3 +1,9 @@ +Sun Oct 18 22:33:25 2009 Tadayoshi Funaba <tadf@d...> + + * lib/date.rb: do not require lib/delta.rb. + + * lib/date/delta.rb: follows the above change. + Sun Oct 18 19:14:21 2009 Tanaka Akira <akr@f...> * parse.y (is_special_global_name): add boundary check. Index: lib/date/delta.rb =================================================================== --- lib/date/delta.rb (revision 25392) +++ lib/date/delta.rb (revision 25393) @@ -1,5 +1,6 @@ # delta.rb: Written by Tadayoshi Funaba 2004-2009 +require 'date' require 'date/delta/parser' class Date @@ -398,3 +399,33 @@ end end + +vsave = $VERBOSE +$VERBOSE = false + +class Date + + def + (n) + case n + when Numeric; return self.class.new!(@ajd + n, @of, @sg) + when Delta + d = n.__send__(:delta) + return (self >> d.imag) + d.real + end + raise TypeError, 'expected numeric' + end + + def - (x) + case x + when Numeric; return self.class.new!(@ajd - x, @of, @sg) + when Date; return @ajd - x.ajd + when Delta + d = x.__send__(:delta) + return (self << d.imag) - d.real + end + raise TypeError, 'expected numeric' + end + +end + +$VERBOSE = vsave Index: lib/date.rb =================================================================== --- lib/date.rb (revision 25392) +++ lib/date.rb (revision 25393) @@ -194,7 +194,6 @@ # puts secs_to_new_year() require 'date/format' -require 'date/delta' # Class representing a date. # @@ -1337,9 +1336,6 @@ def + (n) case n when Numeric; return self.class.new!(@ajd + n, @of, @sg) - when Delta - d = n.__send__(:delta) - return (self >> d.imag) + d.real end raise TypeError, 'expected numeric' end @@ -1356,11 +1352,8 @@ case x when Numeric; return self.class.new!(@ajd - x, @of, @sg) when Date; return @ajd - x.ajd - when Delta - d = x.__send__(:delta) - return (self << d.imag) - d.real end - raise TypeError, 'expected numeric' + raise TypeError, 'expected numeric or date' end # Compare this date with another date. -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/