James

Thanks for the comments.  This -

> @display.strftime("%H:%M").sub(/\d$/, "~")

is certainly more elegant than mine.

Gavin - I was able to test the code with your test class.  I don't  
claim to fully understand it yet though.  It's good to finally do  
some test driven development.

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.

Thanks

Robert


On 30 Oct 2006, at 14:08, James Edward Gray II wrote:

> On Oct 29, 2006, at 6:34 PM, Robert Conn wrote:
>
>> Hi all,
>
> Hello.
>
>> This is my first submission to the list and I'm new to Ruby too.
>
> Welcome!
>
>> Comments and advice would really be appreciated.
>
> My comment is that I wish I wrote Ruby that pretty when I was new.  :)
>
> I'll give a couple super minor suggestions...
>
>>   def initialize(*start_time)
>>     @current_systime = Time.new
>>     @actual = start_time[0] || Time.new
>>     @last_displayed = @actual
>>   end
>
> Why take an Array of arguments but only use the first one?  I think  
> you should drop the slurping operator:
>
> def initialize(start_time)
>   @current_systime = Time.new
>   @actual = start_time || Time.new
>   @last_displayed = @actual
> end
>
>>     # Decide whether to go forward or back 5 mins
>>     if rand(2) == 1
>>       @display = @actual + (5 * 60)
>>     else
>>       @display = @actual - (5 * 60)
>>     end
>
>
> You could shorten that up a bit, though I'm not sure this is as  
> readable:
>
> @display = @actual.send(%w[+ -][rand(2)], 5 * 60)
>
>>     "#{"%02d" % @display.hour}:#{("%02d" % @display.min.to_s) 
>> [0..0]}~"
>
> Perhaps the this is more straight forward:
>
> @display.strftime("%H:%M").sub(/\d$/, "~")
>
> Hope that gives you some new ideas.
>
> James Edward Gray II
>