Class: Multibases::Base2::Table
- Defined in:
- lib/multibases/base2.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.
34 35 36 37 38 39 40 41 42 43 |
# 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 |
Class Method Details
.from(alphabet, **opts) ⇒ Object
27 28 29 30 31 32 |
# 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 |