-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Gavin, This looks very interesting -- thanks for the pointer. I'll take a look at it and see how i can adapt it to my situation. (Sam, you were headed right along the same path so this certainly seems to be the right way) Thanks again, Derek Gavin Kistner wrote: | On Feb 10, 2005, at 6:29 AM, Derek Wyatt wrote: | |> I've been trying for a while to subclass Time, but i'm hitting some |> problems. I tried simply overriding the methods in Time itself but |> after about 5 minutes i realized that i needed the old behaviour as |> well, so subclassing seems better. I'm hitting the same problems with |> wrapping the object as well. | | | In my MutableTime class [1], I wrapped Time, rather than inheriting from | it, and used method_missing to pass functions along to time. | | Tiny snippets: | | class MutableTime | include Comparable | | def initialize( dateString_Seconds_Time_orYear = nil , | *dateTimePieces ) | #... | @t=Time.now | end | | def method_missing(meth, *args, &block) # :nodoc: | @t.send(meth, *args, &block) | end | | def date=(n) | @t+=(n-date)*86400; | end | | def +(n) | (d=self.dup).date+=n | d; | end | end | | | [1] http://phrogz.net/RubyLibs/rdoc/files/MutableTime_rb.html | | | -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.4 (MingW32) iD8DBQFCC3TRxPPkePIbSlwRAk7YAKCUYiJicPGnf2ayonXUr/SvnQosjwCgtrmp bA+tVEJl9NmxXnKaTQGT5k0= =440j -----END PGP SIGNATURE-----