A Clockwork Ruby - A clock class for use with time of day.


clock = Clock.now
=>  5:28 PM

other_clock = Clock.new(13,3)
=>  1:03 PM

clock.hour
=> 17 
clock.min
=> 30 
clock.sec
=> 21 
clock.usec
=> 266631

clock.hour = 23
=> 23

Clock.from_i(12345)
=>  3:25 AM

Clock.now.to_i
=> 63393

clock == other_clock
=> false

clock > other_clock
=> true

# Takes same arguments as strftime
clock.strfclock('%H:%M:%S')
=> "17:30:21"

Credits

Shared Shoulda is maintained by Mike Taylor and is funded by BookRenter.com. Help provided by Michael Pearce, and Miguel Huibonhoa.

BookRenter.com Logo

Copyright

Copyright (c) 2012 Bookrenter.com. See LICENSE.txt for further details.