Sha256: 01958740e106269b91d8c374aef0d6665138c38b8faac69317db9f336b90e7e8
Contents?: true
Size: 696 Bytes
Versions: 12
Compression:
Stored size: 696 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 # rubocop:disable Style/OpMethod def +(hours=0, minutes) @internal += hours * 60 + minutes self end def -(*args) self.+(*args.map(&:-@)) end # rubocop:enable Style/OpMethod 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
12 entries across 12 versions & 1 rubygems