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.180 tracks/lua/exercises/clock/example.lua
trackler-2.2.1.179 tracks/lua/exercises/clock/example.lua
trackler-2.2.1.178 tracks/lua/exercises/clock/example.lua
trackler-2.2.1.177 tracks/lua/exercises/clock/example.lua
trackler-2.2.1.176 tracks/lua/exercises/clock/example.lua
trackler-2.2.1.175 tracks/lua/exercises/clock/example.lua
trackler-2.2.1.174 tracks/lua/exercises/clock/example.lua
trackler-2.2.1.173 tracks/lua/exercises/clock/example.lua
trackler-2.2.1.172 tracks/lua/exercises/clock/example.lua
trackler-2.2.1.171 tracks/lua/exercises/clock/example.lua
trackler-2.2.1.170 tracks/lua/exercises/clock/example.lua
trackler-2.2.1.169 tracks/lua/exercises/clock/example.lua
trackler-2.2.1.167 tracks/lua/exercises/clock/example.lua
trackler-2.2.1.166 tracks/lua/exercises/clock/example.lua
trackler-2.2.1.165 tracks/lua/exercises/clock/example.lua
trackler-2.2.1.164 tracks/lua/exercises/clock/example.lua
trackler-2.2.1.163 tracks/lua/exercises/clock/example.lua
trackler-2.2.1.162 tracks/lua/exercises/clock/example.lua
trackler-2.2.1.161 tracks/lua/exercises/clock/example.lua
trackler-2.2.1.160 tracks/lua/exercises/clock/example.lua