Module:File link: Difference between revisions

From the Croc Wiki, the Croc encyclopedia
Jump to navigationJump to search
add start, end, and thumbtime
(don't include the library name in checkSelf method names)
(add start, end, and thumbtime)
Line 184:
checkType('fileLink:lang', 1, s, 'string', true)
data.theLang = s
return self
end
 
local function checkTypeStringOrNum(funcName, pos, arg)
local argType = type(arg)
if argType ~= 'nil' and argType ~= 'string' and argType ~= 'number' then
error(string.format(
"bad argument #%d to '%s' (string or number expected, got %s)",
pos,
funcName,
argType
), 3)
end
end
function data:startTime(time)
checkSelf(self, 'startTime')
checkTypeStringOrNum('fileLink:startTime', 1, time)
data.theStartTime = time
return self
end
function data:endTime(time)
checkSelf(self, 'endTime')
checkTypeStringOrNum('fileLink:endTime', 1, time)
data.theEndTime = time
return self
end
function data:thumbTime(time)
checkSelf(self, 'thumbTime')
checkTypeStringOrNum('fileLink:thumbTime', 1, time)
data.theThumbTime = time
return self
end
Line 236 ⟶ 269:
-- Render named parameters.
-- That includes link, alt, page, class, lang, start, end, and langthumbtime.
do
local namedParameters = {'link', 'alt', 'page', 'class', 'lang'}
{'link', 'theLink'},
for i, parameter in ipairs(namedParameters) do
{'alt', 'theAlt'},
local dataField = 'the' .. parameter:sub(1, 1):upper() .. parameter:sub(2, -1)
{'page', 'thePage'},
local value = data[dataField]
{'class', 'theClass'},
{'lang', 'theLang'},
{'start', 'theStartTime'},
{'end', 'theEndTime'},
{'thumbtime', 'theThumbTime'}
}
for i, parametert in ipairs(namedParameters) do
local parameter = t[1]
local value = data[dataFieldt[2]]
if value then
ret[#ret + 1] = parameter .. '=' .. tostring(value)
Cookies help us deliver our services. By using our services, you agree to our use of cookies.

Navigation menu