Class: CloudRailSi::ServiceCode::Uint8ToBase64

Inherits:
Object
  • Object
show all
Defined in:
lib/cloudrail_si/servicecode/commands/array/Uint8ToBase64.rb

Instance Method Summary collapse

Instance Method Details

#execute(environment, parameters) ⇒ Object



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

#get_identifierObject



7
8
9
# File 'lib/cloudrail_si/servicecode/commands/array/Uint8ToBase64.rb', line 7

def get_identifier
     'array.uint8ToBase64'
end