Module: CryptBufferConcern::Convertable

Included in:
CryptBuffer
Defined in:
lib/crypto-toolbox/crypt_buffer/concerns/convertable.rb

Instance Method Summary collapse

Instance Method Details

#base64(strict: true) ⇒ Object

[View source]

27
28
29
# File 'lib/crypto-toolbox/crypt_buffer/concerns/convertable.rb', line 27

def base64(strict: true)
  strict ?  Base64.strict_encode64(str) : Base64.encode64(str) 
end

#bitsObject

[View source]

19
20
21
# File 'lib/crypto-toolbox/crypt_buffer/concerns/convertable.rb', line 19

def bits
  map{|b| "%08d" % b.to_s(2) }
end

#charsObject Also known as: c

[View source]

9
10
11
# File 'lib/crypto-toolbox/crypt_buffer/concerns/convertable.rb', line 9

def chars
  map(&:chr)
end

#hexObject Also known as: h

[View source]

3
4
5
# File 'lib/crypto-toolbox/crypt_buffer/concerns/convertable.rb', line 3

def hex
  bytes2hex(bytes).upcase
end

#strObject Also known as: s

[View source]

14
15
16
# File 'lib/crypto-toolbox/crypt_buffer/concerns/convertable.rb', line 14

def str
  map(&:chr).join
end

#to_crypt_bufferObject

[View source]

31
32
33
# File 'lib/crypto-toolbox/crypt_buffer/concerns/convertable.rb', line 31

def to_crypt_buffer
  self
end

#to_sObject

[View source]

23
24
25
# File 'lib/crypto-toolbox/crypt_buffer/concerns/convertable.rb', line 23

def to_s
  str
end