Module: RadixEncoding::Encoding::Validations

Included in:
RadixEncoding::Encoding
Defined in:
lib/radix_encoding/encoding/validations.rb

Instance Method Summary collapse

Instance Method Details

#alphabetObject

Raises:

  • (NotImplementedError)


8
9
10
# File 'lib/radix_encoding/encoding/validations.rb', line 8

def alphabet
  raise NotImplementedError
end

#radixObject

Raises:

  • (NotImplementedError)


12
13
14
# File 'lib/radix_encoding/encoding/validations.rb', line 12

def radix
  raise NotImplementedError
end

#validate!Object



16
17
18
# File 'lib/radix_encoding/encoding/validations.rb', line 16

def validate!
  validate_alphabet_length!
end

#validate_alphabet_length!Object



20
21
22
23
24
25
26
27
# File 'lib/radix_encoding/encoding/validations.rb', line 20

def validate_alphabet_length!
  return if alphabet.bytesize >= radix

  raise AlphabetTooShortError.new(
    alphabet_bytesize: alphabet.bytesize,
    radix: radix,
  )
end