11
12
13
14
15
16
17
18
19
20
21
22
|
# File 'lib/cloudrail_si/servicecode/commands/array/Uint8ToBase64.rb', line 11
def execute(environment, parameters)
Helper.assert(parameters.length >= 2 &&
Helper.is_var_address(parameters[0]) &&
Helper.is_var_address(parameters[1]))
result_var = parameters[0]
source_array = Helper.resolve(environment, parameters[1])
url_safe = !!Helper.resolve(environment, parameters[2]) if (parameters.length > 2)
Helper.assert(Helper.is_array(source_array))
packed = source_array.pack('c*')
base64_string = Base64Encode.encode([packed].pack("H*"), false, url_safe)
environment.set_variable(result_var, base64_string)
end
|