Module:File link: Difference between revisions
don't include the library name in checkSelf method names
(rename the image table to a fileLink table, seeing as this code is applicable to all file links) |
(don't include the library name in checkSelf method names) |
||
Line 23: | Line 23: | ||
function data:name(s) | function data:name(s) | ||
checkSelf(self, ' | checkSelf(self, 'name') | ||
checkType('fileLink:name', 1, s, 'string') | checkType('fileLink:name', 1, s, 'string') | ||
data.theName = s | data.theName = s | ||
Line 30: | Line 30: | ||
function data:format(s, filename) | function data:format(s, filename) | ||
checkSelf(self, ' | checkSelf(self, 'format') | ||
checkType('fileLink:format', 1, s, 'string', true) | checkType('fileLink:format', 1, s, 'string', true) | ||
checkType('fileLink:format', 2, format, 'string', true) | checkType('fileLink:format', 2, format, 'string', true) | ||
Line 62: | Line 62: | ||
function data:width(px) | function data:width(px) | ||
checkSelf(self, ' | checkSelf(self, 'width') | ||
checkType('fileLink:width', 1, px, 'number', true) | checkType('fileLink:width', 1, px, 'number', true) | ||
if px and data.isUpright then | if px and data.isUpright then | ||
Line 72: | Line 72: | ||
function data:height(px) | function data:height(px) | ||
checkSelf(self, ' | checkSelf(self, 'height') | ||
checkType('fileLink:height', 1, px, 'number', true) | checkType('fileLink:height', 1, px, 'number', true) | ||
if px and data.isUpright then | if px and data.isUpright then | ||
Line 82: | Line 82: | ||
function data:upright(isUpright, factor) | function data:upright(isUpright, factor) | ||
checkSelf(self, ' | checkSelf(self, 'upright') | ||
checkType('fileLink:upright', 1, isUpright, 'boolean', true) | checkType('fileLink:upright', 1, isUpright, 'boolean', true) | ||
checkType('fileLink:upright', 2, factor, 'number', true) | checkType('fileLink:upright', 2, factor, 'number', true) | ||
Line 94: | Line 94: | ||
function data:resetSize() | function data:resetSize() | ||
checkSelf(self, ' | checkSelf(self, 'resetSize') | ||
for i, field in ipairs{'theWidth', 'theHeight', 'isUpright', 'uprightFactor'} do | for i, field in ipairs{'theWidth', 'theHeight', 'isUpright', 'uprightFactor'} do | ||
data[field] = nil | data[field] = nil | ||
Line 102: | Line 102: | ||
function data:location(s) | function data:location(s) | ||
checkSelf(self, ' | checkSelf(self, 'location') | ||
checkType('fileLink:location', 1, s, 'string', true) | checkType('fileLink:location', 1, s, 'string', true) | ||
local validLocations = { | local validLocations = { | ||
Line 122: | Line 122: | ||
function data:alignment(s) | function data:alignment(s) | ||
checkSelf(self, ' | checkSelf(self, 'alignment') | ||
checkType('fileLink:alignment', 1, s, 'string', true) | checkType('fileLink:alignment', 1, s, 'string', true) | ||
local validAlignments = { | local validAlignments = { | ||
Line 146: | Line 146: | ||
function data:border(hasBorder) | function data:border(hasBorder) | ||
checkSelf(self, ' | checkSelf(self, 'border') | ||
checkType('fileLink:border', 1, hasBorder, 'boolean', true) | checkType('fileLink:border', 1, hasBorder, 'boolean', true) | ||
data.hasBorder = hasBorder | data.hasBorder = hasBorder | ||
Line 153: | Line 153: | ||
function data:link(s) | function data:link(s) | ||
checkSelf(self, ' | checkSelf(self, 'link') | ||
checkType('fileLink:link', 1, s, 'string', true) | checkType('fileLink:link', 1, s, 'string', true) | ||
data.theLink = s | data.theLink = s | ||
Line 160: | Line 160: | ||
function data:alt(s) | function data:alt(s) | ||
checkSelf(self, ' | checkSelf(self, 'alt') | ||
checkType('fileLink:alt', 1, s, 'string', true) | checkType('fileLink:alt', 1, s, 'string', true) | ||
data.theAlt = s | data.theAlt = s | ||
Line 167: | Line 167: | ||
function data:page(num) | function data:page(num) | ||
checkSelf(self, ' | checkSelf(self, 'page') | ||
checkType('fileLink:page', 1, num, 'number', true) | checkType('fileLink:page', 1, num, 'number', true) | ||
data.thePage = s | data.thePage = s | ||
Line 174: | Line 174: | ||
function data:class(s) | function data:class(s) | ||
checkSelf(self, ' | checkSelf(self, 'class') | ||
checkType('fileLink:class', 1, s, 'string', true) | checkType('fileLink:class', 1, s, 'string', true) | ||
data.theClass = s | data.theClass = s | ||
Line 181: | Line 181: | ||
function data:lang(s) | function data:lang(s) | ||
checkSelf(self, ' | checkSelf(self, 'lang') | ||
checkType('fileLink:lang', 1, s, 'string', true) | checkType('fileLink:lang', 1, s, 'string', true) | ||
data.theLang = s | data.theLang = s | ||
Line 188: | Line 188: | ||
function data:caption(s) | function data:caption(s) | ||
checkSelf(self, ' | checkSelf(self, 'caption') | ||
checkType('fileLink:caption', 1, s, 'string', true) | checkType('fileLink:caption', 1, s, 'string', true) | ||
data.theCaption = s | data.theCaption = s | ||
Line 195: | Line 195: | ||
function data:render() | function data:render() | ||
checkSelf(self, ' | checkSelf(self, 'render') | ||
local ret = {} | local ret = {} | ||