class Multibases::Base2::Table

Public Class Methods

from(alphabet, **opts) click to toggle source
# File lib/multibases/base2.rb, line 27
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/base2.rb, line 34
def initialize(ords, **opts)
  ords = ords.uniq
  if ords.length != 2
    raise ArgumentError,
          'Expected chars to contain 2 exactly. Actual: ' \
          "#{ords.length} characters."
  end

  super ords, **opts
end