Module: CryptBufferConcern::Convertable
- Included in:
- CryptBuffer
- Defined in:
- lib/crypto-toolbox/crypt_buffer/concerns/convertable.rb
Instance Method Summary collapse
- #base64(strict: true) ⇒ Object
- #bits ⇒ Object
- #chars ⇒ Object (also: #c)
- #hex ⇒ Object (also: #h)
- #str ⇒ Object (also: #s)
- #to_crypt_buffer ⇒ Object
- #to_s ⇒ Object
Instance Method Details
permalink #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 |
permalink #bits ⇒ Object
[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 |
permalink #chars ⇒ Object 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 |
permalink #hex ⇒ Object 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 |
permalink #str ⇒ Object 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 |
permalink #to_crypt_buffer ⇒ Object
[View source]
31 32 33 |
# File 'lib/crypto-toolbox/crypt_buffer/concerns/convertable.rb', line 31 def to_crypt_buffer self end |
permalink #to_s ⇒ Object
[View source]
23 24 25 |
# File 'lib/crypto-toolbox/crypt_buffer/concerns/convertable.rb', line 23 def to_s str end |