Anonymous user
Module:File link: Difference between revisions
add start, end, and thumbtime
Enwikipedia>Mr. Stradivarius (don't include the library name in checkSelf method names) |
Enwikipedia>Mr. Stradivarius (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
do
local namedParameters = {
{'link', 'theLink'},
for i, parameter in ipairs(namedParameters) do▼
{'alt', 'theAlt'},
{'page', 'thePage'},
local value = data[dataField]▼
{'class', 'theClass'},
{'lang', 'theLang'},
{'start', 'theStartTime'},
{'end', 'theEndTime'},
{'thumbtime', 'theThumbTime'}
}
local parameter = t[1]
if value then
ret[#ret + 1] = parameter .. '=' .. tostring(value)
|