Update ldoc comments

This commit is contained in:
Insality
2019-12-05 22:05:06 +03:00
parent f8a3b6f632
commit 88a37f77af
9 changed files with 172 additions and 86 deletions

View File

@@ -1,25 +1,27 @@
--- Druid module with utils on string formats
-- @module helper.formats
local const = require("druid.const")
local M = {}
local ZERO = "0"
--- Return number with zero number prefix
-- @param num number for conversion
-- @param count count of numerals
-- @function formats.add_prefix_zeros
-- @tparam number num Number for conversion
-- @tparam number 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
result = const.ZERO..result
end
return result
end
--- Convert seconds to string minutes:seconds
-- @param num number of seconds
-- @function formats.second_string_min
-- @tparam number sec Seconds
-- @return string minutes:seconds
function M.second_string_min(sec)
local mins = math.floor(sec / 60)
@@ -29,8 +31,9 @@ end
--- Interpolate string with named Parameters in Table
-- @param s string for interpolate
-- @param tab table with parameters
-- @function formats.second_string_min
-- @tparam string s Target string
-- @tparam table tab Table with parameters
-- @return string with replaced parameters
function M.interpolate_string(s, tab)
return (s:gsub('($%b{})', function(w) return tab[w:sub(3, -2)] or w end))