Module:PriceCalculator: Difference between revisions
No edit summary |
No edit summary |
||
Line 1: | Line 1: | ||
local p = {} | local p = {} | ||
function p._calculate(price, priceType) | function p._calculate(price, priceType) | ||
price = tonumber(price) | price = tonumber(price) | ||
Line 19: | Line 18: | ||
end | end | ||
return math.floor(price * factor + 0.5) | return math.floor(price * factor + 0.5) | ||
end | end | ||
function p.calculate(frame) | function p.calculate(frame) | ||
local args = frame:getParent().args | local args = frame:getParent().args | ||
Line 30: | Line 28: | ||
end | end | ||
return setmetatable(p, { __call = function(_, frame) return p.calculate(frame) end }) | -- This makes the module callable directly without a function name | ||
return setmetatable(p, { | |||
__call = function(_, frame) | |||
return p.calculate(frame) | |||
end | |||
}) |