Module:Infobox interval: Difference between revisions
Jump to navigation
Jump to search
m Bugfix |
mNo edit summary |
||
| Line 5: | Line 5: | ||
function p.infobox_interval(frame) | function p.infobox_interval(frame) | ||
local debug_mode = frame.args['debug'] ~= nil | |||
-- TODO: better input parsing | -- TODO: better input parsing | ||
local ratio_arg = frame.args['Ratio'] or '2/1' | local ratio_arg = frame.args['Ratio'] or '2/1' | ||
| Line 61: | Line 63: | ||
-- TODO: Sound, xen-calc (colspan 2) | -- TODO: Sound, xen-calc (colspan 2) | ||
local s = infobox.build( | |||
'<u>Interval information</u>', | '<u>Interval information</u>', | ||
infobox_data | infobox_data | ||
) .. cats | ) | ||
if not debug_mode then | |||
s = s .. cats | |||
end | |||
return s | |||
end | end | ||
return p | return p | ||
Revision as of 12:23, 9 October 2022
- This module should not be invoked directly; use its corresponding template instead: Template:Infobox interval.
This module generates an infobox providing information about a given interval.
| Introspection summary for Module:Infobox interval | |||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
| ||||||||||||||||||
No function descriptions were provided. The Lua code may have further information.
local p = {}
local rat = require('Module:Rational')
local i = require('Module:Interval')
local infobox = require('Module:Infobox')
function p.infobox_interval(frame)
local debug_mode = frame.args['debug'] ~= nil
-- TODO: better input parsing
local ratio_arg = frame.args['Ratio'] or '2/1'
local ratio = rat.parse(ratio_arg) or rat.new(2)
local infobox_data = {}
local cats = '[[Category:Rational intervals]]'
table.insert(infobox_data, {
'Ratio',
rat.as_ratio(ratio)
})
table.insert(infobox_data, {
'[[Monzo]]',
rat.as_ket(ratio, frame)
})
table.insert(infobox_data, {
'Size in [[cent]]s',
i._to_cents(rat.as_float(ratio), 6)
})
local name = frame.args['Name']
if name and #name > 0 then
local caption = 'Name'
if name:match(',') then caption = 'Names' end
table.insert(infobox_data, {
caption,
name
})
else
cats = cats .. '[[Category:Todo:add interval name]]'
table.insert(infobox_data, {
'Name(s)',
'<abbr title="missing value for parameter \'Name\'">\'\'missing\'\'</abbr></span><sup>[[Template:Infobox Interval| ? ]]</sup>'
})
end
-- TODO: compute?
local colour_name = frame.args['Color name']
if colour_name and #colour_name > 0 then
table.insert(infobox_data, {
'[[Color notation|Color name]]',
colour_name
})
end
-- TODO: compute
local FJS_name = frame.args['FJS name']
if FJS_name and #FJS_name > 0 then
table.insert(infobox_data, {
'[[Functional Just System|FJS name]]',
FJS_name
})
end
-- TODO: Sound, xen-calc (colspan 2)
local s = infobox.build(
'<u>Interval information</u>',
infobox_data
)
if not debug_mode then
s = s .. cats
end
return s
end
return p