Class: Base32::Encoder

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(str, alphabet = Base32::Alphabet::CHARS) ⇒ Encoder

Returns a new instance of Encoder.



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

def initialize(str, alphabet = Base32::Alphabet::CHARS)
  @str      = str
  @alphabet = alphabet
end

Instance Attribute Details

#alphabetObject (readonly)

Returns the value of attribute alphabet.



5
6
7
# File 'lib/base32/encoder.rb', line 5

def alphabet
  @alphabet
end

#strObject (readonly)

Returns the value of attribute str.



5
6
7
# File 'lib/base32/encoder.rb', line 5

def str
  @str
end

Instance Method Details

#callObject



12
13
14
# File 'lib/base32/encoder.rb', line 12

def call
  Base32::Chunk.call(str, 5, alphabet).collect(&:encode).flatten.join
end