Class: CloudRailSi::ServiceCode::Base64Encode
- Inherits:
-
Object
- Object
- CloudRailSi::ServiceCode::Base64Encode
- Defined in:
- lib/cloudrail_si/servicecode/commands/string/Base64Encode.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.encode(s, line_break, web_safe) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/cloudrail_si/servicecode/commands/string/Base64Encode.rb', line 29 def self.encode(s, line_break, web_safe) if (!line_break && !web_safe) return Base64.strict_encode64(s) elsif (!line_break && web_safe) return Base64.urlsafe_encode64(s) elsif (line_break && !web_safe) # breaks after every 60 characters which is slightly different than the node version return Base64.encode64(s) else raise Errors::InternalError.new('param combination not supported for Ruby Base64Encode') end end |
Instance Method Details
#execute(environment, parameters) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/cloudrail_si/servicecode/commands/string/Base64Encode.rb', line 14 def execute(environment, parameters) Helper.assert(parameters.length >= 2 && Helper.is_var_address(parameters[0])) result_var = parameters[0] source_string = Helper.resolve(environment, parameters[1]) Helper.assert(Helper.is_string(source_string)) line_break = false web_safe = false line_break = !!Helper.resolve(environment, parameters[2]) if (parameters.length >= 3) web_safe = !!Helper.resolve(environment, parameters[3]) if (parameters.length >= 4) result_string = Base64Encode::encode(source_string, line_break, web_safe) environment.set_variable(result_var, result_string) end |
#get_identifier ⇒ Object
10 11 12 |
# File 'lib/cloudrail_si/servicecode/commands/string/Base64Encode.rb', line 10 def get_identifier 'string.base64encode' end |