Class: Moneta::Transforms::Hex
- Inherits:
-
Moneta::Transform
- Object
- Moneta::Transform
- Moneta::Transforms::Hex
- Defined in:
- lib/moneta/transforms/hex.rb
Overview
Encodes the string as a string representation of the bytes in hexadecimal
Instance Method Summary collapse
-
#decode(value) ⇒ String
Decodes from hexadecimal.
-
#encode(value) ⇒ String
Encodes to hexadecimal.
Methods inherited from Moneta::Transform
#decodable?, delegate_to, #initialize, #method_missing, #respond_to_missing?
Constructor Details
This class inherits a constructor from Moneta::Transform
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Moneta::Transform
Instance Method Details
#decode(value) ⇒ String
Decodes from hexadecimal
20 21 22 |
# File 'lib/moneta/transforms/hex.rb', line 20 def decode(value) [value].pack("H*") end |
#encode(value) ⇒ String
Encodes to hexadecimal
12 13 14 |
# File 'lib/moneta/transforms/hex.rb', line 12 def encode(value) value.unpack1("H*") end |