class Multibases::Base16::Table

Public Class Methods

from(alphabet, **opts) click to toggle source
# File lib/multibases/base16.rb, line 34
def self.from(alphabet, **opts)
  alphabet = alphabet.bytes if alphabet.respond_to?(:bytes)
  alphabet.map!(&:ord)

  new(alphabet, **opts)
end
new(ords, **opts) click to toggle source
Calls superclass method
# File lib/multibases/base16.rb, line 41
def initialize(ords, **opts)
  ords = ords.uniq
  if ords.length < 16 || ords.length > 17
    # Allow 17 for stale padding that does nothing
    raise ArgumentError,
          'Expected alphabet to contain 16 exactly. Actual: ' \
          "#{ords.length} characters."
  end

  super ords, **opts
end