Class: Base32::Alphabet

Inherits:
Object
  • Object
show all
Defined in:
lib/base32/alphabet.rb

Constant Summary collapse

CHARS =
'ABCDEFGHIJKLMNOPQRSTUVWXYZ234567'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(chars) ⇒ Alphabet

Returns a new instance of Alphabet.



11
12
13
# File 'lib/base32/alphabet.rb', line 11

def initialize(chars)
  self.chars = chars
end

Instance Attribute Details

#charsObject Also known as: to_s

Returns the value of attribute chars.



7
8
9
# File 'lib/base32/alphabet.rb', line 7

def chars
  @chars
end

Instance Method Details

#chars_valid?(chars) ⇒ Boolean

Returns:

  • (Boolean)


27
28
29
# File 'lib/base32/alphabet.rb', line 27

def chars_valid?(chars)
  chars.bytes.to_a.size == 32 && chars.bytes.to_a.uniq.size == 32
end

#inspectObject



15
16
17
# File 'lib/base32/alphabet.rb', line 15

def inspect
  "#<#{self.class}:#{chars.inspect}>"
end