Class: Multibases::Base64::Table
- Defined in:
- lib/multibases/base64.rb
Instance Attribute Summary
Attributes inherited from OrdTable
#base, #encoding, #factor, #padder
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(ords, **opts) ⇒ Table
constructor
A new instance of Table.
Methods inherited from OrdTable
#alphabet, #eql?, #hash, #strict?, #tr_ords
Constructor Details
#initialize(ords, **opts) ⇒ Table
Returns a new instance of Table.
42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/multibases/base64.rb', line 42 def initialize(ords, **opts) ords = ords.uniq if ords.length < 64 || ords.length > 65 raise ArgumentError, 'Expected alphabet to contain 64 characters or 65 + 1 ' \ "padding character. Actual: #{ords.length} characters" end padder = nil *ords, padder = ords if ords.length == 65 super(ords, padder: padder, **opts) end |
Class Method Details
.from(alphabet, **opts) ⇒ Object
35 36 37 38 39 40 |
# File 'lib/multibases/base64.rb', line 35 def self.from(alphabet, **opts) alphabet = alphabet.bytes if alphabet.respond_to?(:bytes) alphabet.map!(&:ord) new(alphabet, **opts) end |