Sha256: d24f27e736ec401fa2b7eee8258583ef1adfd75beb03a42ea5a1cebd12be4faa

Contents?: true

Size: 577 Bytes

Versions: 396

Compression:

Stored size: 577 Bytes

Contents

local Clock = {}
Clock.__index = Clock

function Clock:__tostring()
  return string.format('%02d:%02d', math.floor(self.minutes / 60) % 24, self.minutes % 60)
end

Clock.tostring = Clock.__tostring

function Clock:plus(minutes)
  self.minutes = self.minutes + minutes
  return self
end

function Clock:minus(minutes)
  self.minutes = self.minutes - minutes
  return self
end

function Clock:equals(other)
  return tostring(self) == tostring(other)
end

function Clock.at(hours, minutes)
  return setmetatable({ minutes = hours * 60 + (minutes or 0) }, Clock)
end

return Clock

Version data entries

396 entries across 396 versions & 1 rubygems

Version Path
trackler-2.2.1.78 tracks/lua/exercises/clock/example.lua
trackler-2.2.1.77 tracks/lua/exercises/clock/example.lua
trackler-2.2.1.76 tracks/lua/exercises/clock/example.lua
trackler-2.2.1.75 tracks/lua/exercises/clock/example.lua
trackler-2.2.1.74 tracks/lua/exercises/clock/example.lua
trackler-2.2.1.73 tracks/lua/exercises/clock/example.lua
trackler-2.2.1.72 tracks/lua/exercises/clock/example.lua
trackler-2.2.1.71 tracks/lua/exercises/clock/example.lua
trackler-2.2.1.70 tracks/lua/exercises/clock/example.lua
trackler-2.2.1.69 tracks/lua/exercises/clock/example.lua
trackler-2.2.1.68 tracks/lua/exercises/clock/example.lua
trackler-2.2.1.67 tracks/lua/exercises/clock/example.lua
trackler-2.2.1.66 tracks/lua/exercises/clock/example.lua
trackler-2.2.1.65 tracks/lua/exercises/clock/example.lua
trackler-2.2.1.64 tracks/lua/exercises/clock/example.lua
trackler-2.2.1.63 tracks/lua/exercises/clock/example.lua
trackler-2.2.1.62 tracks/lua/exercises/clock/example.lua
trackler-2.2.1.61 tracks/lua/exercises/clock/example.lua
trackler-2.2.1.60 tracks/lua/exercises/clock/example.lua
trackler-2.2.1.59 tracks/lua/exercises/clock/example.lua