diff options
author | Adrian C. (anrxc) <anrxc@sysphere.org> | 2010-02-20 03:24:42 +0100 |
---|---|---|
committer | Adrian C. (anrxc) <anrxc@sysphere.org> | 2010-02-20 03:24:42 +0100 |
commit | e29ea6288a04100850efad7f1aa0cd747b82dc78 (patch) | |
tree | 132b1a966e50840760b12bf64d184d78853254dc /helpers.lua | |
parent | f4cd746188b7508f2045eb4ce0d215ba3b27053e (diff) | |
download | vicious-legacy-e29ea6288a04100850efad7f1aa0cd747b82dc78.tar.xz |
helpers: uformat helper replaces formatting done by widgets
Diffstat (limited to 'helpers.lua')
-rw-r--r-- | helpers.lua | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/helpers.lua b/helpers.lua index c731ae8..e8d6d6c 100644 --- a/helpers.lua +++ b/helpers.lua @@ -12,7 +12,8 @@ local io = { open = io.open } local setmetatable = setmetatable local string = { sub = string.sub, - gsub = string.gsub + gsub = string.gsub, + format = string.format } -- }}} @@ -51,6 +52,16 @@ function format(format, args) end -- }}} +-- {{{ Format units to one decimal point +function uformat(array, key, value, unit) + for u, v in pairs(unit) do + array["{"..key.."_"..u.."}"] = string.format("%.1f", value/v) + end + + return array +end +-- }}} + -- {{{ Escape a string function escape(text) local xml_entities = { |