Sha256: fc1d9559d9b265613fff51f9e9cc891248e2ed689eabab7afe30ed0c363a9a39
Contents?: true
Size: 627 Bytes
Versions: 384
Compression:
Stored size: 627 Bytes
Contents
module BookKeeping VERSION = 2 end # Clock without dates exercise class Clock def self.at(*args) Clock.new(*args) end def initialize(hours=0, minutes=0) @internal = hours * 60 + minutes end def +(hours=0, minutes) @internal += hours * 60 + minutes self end def -(*args) self.+(*args.map(&:-@)) end def ==(other) to_s == other.to_s end def to_s format '%02i:%02i', *time end private def time [hours_from(@internal), just_minutes(@internal)] end def hours_from(minutes) minutes / 60 % 24 end def just_minutes(minutes) minutes % 60 end end
Version data entries
384 entries across 384 versions & 1 rubygems