Class: Multibases::BaseX::Table

Inherits:
IndexedOrdTable show all
Defined in:
lib/multibases/base_x.rb

Instance Attribute Summary

Attributes inherited from OrdTable

#base, #encoding, #factor, #padder

Class Method Summary collapse

Methods inherited from IndexedOrdTable

#decoded_length, #decoded_zeroes_length, #encoded_length, #encoded_zeroes_length, #index, #initialize, #ord_at, #pad_to_power?, #zero

Methods inherited from OrdTable

#alphabet, #eql?, #hash, #initialize, #strict?, #tr_ords

Constructor Details

This class inherits a constructor from Multibases::IndexedOrdTable

Class Method Details

.from(alphabet, **opts) ⇒ Object

Raises:

  • (ArgumentError)


16
17
18
19
20
21
22
23
# File 'lib/multibases/base_x.rb', line 16

def self.from(alphabet, **opts)
  raise ArgumentError, 'Alphabet too long' if alphabet.length >= 255

  alphabet = alphabet.bytes if alphabet.respond_to?(:bytes)
  alphabet.map!(&:ord)

  new(alphabet, **opts)
end