Class: Multibases::Base32
- Inherits:
-
Object
- Object
- Multibases::Base32
- Defined in:
- lib/multibases/base32.rb
Overview
RFC 3548
Defined Under Namespace
Class Method Summary collapse
Instance Method Summary collapse
- #decode(encoded) ⇒ Object
- #encode(plain) ⇒ Object
-
#initialize(alphabet, strict: false, encoding: nil) ⇒ Base32
constructor
A new instance of Base32.
- #inspect ⇒ Object
Constructor Details
Class Method Details
.decode(plain) ⇒ Object
20 21 22 |
# File 'lib/multibases/base32.rb', line 20 def self.decode(plain) Default.decode(plain) end |
.encode(plain) ⇒ Object
16 17 18 |
# File 'lib/multibases/base32.rb', line 16 def self.encode(plain) Default.encode(plain) end |
Instance Method Details
#decode(encoded) ⇒ Object
95 96 97 98 99 |
# File 'lib/multibases/base32.rb', line 95 def decode(encoded) return DecodedByteArray::EMPTY if encoded.empty? DecodedByteArray.new(chunks(encoded, 8).collect(&:decode).flatten) end |
#encode(plain) ⇒ Object
86 87 88 89 90 91 92 93 |
# File 'lib/multibases/base32.rb', line 86 def encode(plain) return EncodedByteArray::EMPTY if plain.empty? EncodedByteArray.new( chunks(plain, 5).collect(&:encode).flatten, encoding: @table.encoding ) end |
#inspect ⇒ Object
9 10 11 12 13 14 |
# File 'lib/multibases/base32.rb', line 9 def inspect '[Multibases::Base32 ' \ "alphabet=\"#{@table.chars.join}\"" \ "#{@table.strict? ? ' strict' : ''}" \ ']' end |