Module:Sandbox/Greenbreen/PPP
Appearance
local data = require("Module:Sandbox/Greenbreen/PPP/data")
local p = {}
local function getPPP(country, year)
local c = data[country]
if not c then return nil end
year = tonumber(year) or 2016
return c[year]
end
function p.convert(value, country, year)
value = tonumber(value)
if not value or not country then return nil end
local ppp = getPPP(country, year)
if not ppp then return nil end
return value / ppp
end
-- wrapper for template use
function p.convertFrame(frame)
local args = frame:getParent().args
local result = p.convert(args[1], args[2], args[3] or args.year)
if not result then
return "Error: PPP conversion failed"
end
return result
end
return p