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.98 tracks/lua/exercises/clock/example.lua
trackler-2.2.1.97 tracks/lua/exercises/clock/example.lua
trackler-2.2.1.96 tracks/lua/exercises/clock/example.lua
trackler-2.2.1.95 tracks/lua/exercises/clock/example.lua
trackler-2.2.1.94 tracks/lua/exercises/clock/example.lua
trackler-2.2.1.93 tracks/lua/exercises/clock/example.lua
trackler-2.2.1.92 tracks/lua/exercises/clock/example.lua
trackler-2.2.1.91 tracks/lua/exercises/clock/example.lua
trackler-2.2.1.90 tracks/lua/exercises/clock/example.lua
trackler-2.2.1.89 tracks/lua/exercises/clock/example.lua
trackler-2.2.1.88 tracks/lua/exercises/clock/example.lua
trackler-2.2.1.87 tracks/lua/exercises/clock/example.lua
trackler-2.2.1.86 tracks/lua/exercises/clock/example.lua
trackler-2.2.1.85 tracks/lua/exercises/clock/example.lua
trackler-2.2.1.84 tracks/lua/exercises/clock/example.lua
trackler-2.2.1.83 tracks/lua/exercises/clock/example.lua
trackler-2.2.1.82 tracks/lua/exercises/clock/example.lua
trackler-2.2.1.81 tracks/lua/exercises/clock/example.lua
trackler-2.2.1.80 tracks/lua/exercises/clock/example.lua
trackler-2.2.1.79 tracks/lua/exercises/clock/example.lua