check project code style. add .luacheckrc (#7)

This commit is contained in:
Maxim Tuprikov
2019-03-29 00:45:46 +03:00
committed by GitHub
parent 235476fee4
commit 12f5f22b69
12 changed files with 328 additions and 247 deletions

View File

@@ -7,28 +7,31 @@ local ZERO = "0"
-- @param count - count of numerals
-- @return string with need count of zero (1,3) -> 001
function M.add_prefix_zeros(num, count)
local result = tostring(num)
for i = string.len(result), count - 1 do
result = ZERO..result
end
return result
local result = tostring(num)
for i = string.len(result), count - 1 do
result = ZERO..result
end
return result
end
-- Convert seconds to string minutes:seconds
-- @param num - number of seconds
-- @return string minutes:seconds
function M.second_string_min(sec)
local mins = math.floor(sec / 60)
local seconds = math.floor(sec - mins * 60)
return string.format("%.2d:%.2d", mins, seconds)
local mins = math.floor(sec / 60)
local seconds = math.floor(sec - mins * 60)
return string.format("%.2d:%.2d", mins, seconds)
end
-- Interpolate string with named Parameters in Table
-- @param s - string for interpolate
-- @param tab - table with parameters
-- @return string with replaced parameters
function M.interpolate_strinng(s, tab)
return (s:gsub('($%b{})', function(w) return tab[w:sub(3, -2)] or w end))
return (s:gsub('($%b{})', function(w) return tab[w:sub(3, -2)] or w end))
end
return M
return M