From: Robert Conn [mailto:[email protected]]
Gavin - I was able to test the code with your test class. I don’t
claim to fully understand it yet though.
Sorry about that…I wrote it for my own use (no comments, terrible
variable names) and then on a whim decided to post it in case someone
found it helpful.
As a sidenote, I assume Ruby doesn’t support overloaded methods? I
initially tried to implement initialize with 2 methods, one with no
parameters, one with the time parameter but it didn’t work.
Not as such, but you can provide default values (which may involve
calculations, not just constants) for arguments. For example:
class FuzzyTime
def initialize( start_time = Time.new )
p start_time
end
end
FuzzyTime.new
#=> Mon Oct 30 15:28:13 -0700 2006
FuzzyTime.new( Time.at( 0 ) )
#=> Wed Dec 31 17:00:00 -0700 1969