summaryrefslogtreecommitdiff
path: root/misc/freeswitch/scripts/common
diff options
context:
space:
mode:
authorPeter Kozak <spag@golwen.net>2013-03-12 04:19:18 -0400
committerPeter Kozak <spag@golwen.net>2013-03-12 04:19:18 -0400
commitfe41b2cd7c8b466e35e81d9a98e43e6ff465280e (patch)
tree7cc8ebe222c9a7a26a27cd271929c2cfde287adc /misc/freeswitch/scripts/common
parentfa7d8880c101118412b15161b774d21fa230f592 (diff)
to_s functions added
Diffstat (limited to 'misc/freeswitch/scripts/common')
-rw-r--r--misc/freeswitch/scripts/common/array.lua27
1 files changed, 26 insertions, 1 deletions
diff --git a/misc/freeswitch/scripts/common/array.lua b/misc/freeswitch/scripts/common/array.lua
index b93ef69..5683dce 100644
--- a/misc/freeswitch/scripts/common/array.lua
+++ b/misc/freeswitch/scripts/common/array.lua
@@ -45,10 +45,35 @@ function expand_variable(variable_path, variable_sets)
end
end
-
+-- replace variables in a string by array values
function expand_variables(line, ...)
local variable_sets = {...};
return (line:gsub('{([%a%d%._]+)}', function(captured)
return expand_variable(captured, variable_sets);
end))
end
+
+
+-- concatenate array values
+function to_s(array, separator, prefix, suffix)
+ require 'common.str';
+
+ local buffer = '';
+ for key, value in pairs(array) do
+ buffer = common.str.append(buffer, value, separator, prefix, suffix);
+ end
+
+ return buffer;
+end
+
+-- concatenate array keys
+function keys_to_s(array, separator, prefix, suffix)
+ require 'common.str';
+
+ local buffer = '';
+ for key, value in pairs(array) do
+ buffer = common.str.append(buffer, key, separator, prefix, suffix);
+ end
+
+ return buffer;
+end