Module: Base64
- Defined in:
- opal/stdlib/base64.rb
Overview
backtick_javascript: true
Class Method Summary collapse
- .decode64(string) ⇒ Object
- .encode64(string) ⇒ Object
- .strict_decode64(string) ⇒ Object
- .strict_encode64(string) ⇒ Object
- .urlsafe_decode64(string) ⇒ Object
- .urlsafe_encode64(string, padding: true) ⇒ Object
Class Method Details
.decode64(string) ⇒ Object
61 62 63 |
# File 'opal/stdlib/base64.rb', line 61 def self.decode64(string) `decode(string.replace(/\r?\n/g, ''))` end |
.encode64(string) ⇒ Object
65 66 67 |
# File 'opal/stdlib/base64.rb', line 65 def self.encode64(string) `encode(string).replace(/(.{60})/g, "$1\n").replace(/([^\n])$/g, "$1\n")` end |
.strict_decode64(string) ⇒ Object
69 70 71 |
# File 'opal/stdlib/base64.rb', line 69 def self.strict_decode64(string) `decode(string)` end |
.strict_encode64(string) ⇒ Object
73 74 75 |
# File 'opal/stdlib/base64.rb', line 73 def self.strict_encode64(string) `encode(string)` end |
.urlsafe_decode64(string) ⇒ Object
77 78 79 |
# File 'opal/stdlib/base64.rb', line 77 def self.urlsafe_decode64(string) `decode(string.replace(/\-/g, '+').replace(/_/g, '/'))` end |
.urlsafe_encode64(string, padding: true) ⇒ Object
81 82 83 84 85 |
# File 'opal/stdlib/base64.rb', line 81 def self.urlsafe_encode64(string, padding: true) str = `encode(string).replace(/\+/g, '-').replace(/\//g, '_')` str = str.delete('=') unless padding str end |