Module: SecurizeString::BinaryStringDataMethods::InstanceMethods
- Defined in:
- lib/securize_string/binary_string_data_methods.rb
Overview
Adds basic binary data instance methods via an include of SecurizeString::BinaryStringDataMethods.
Instance Method Summary collapse
-
#data_to_hex ⇒ Object
Returns the hexidecimal string representation of the data.
-
#data_to_i ⇒ Object
Returns the data converted from hexidecimal into an integer.
Instance Method Details
#data_to_hex ⇒ Object
Returns the hexidecimal string representation of the data.
43 44 45 |
# File 'lib/securize_string/binary_string_data_methods.rb', line 43 def data_to_hex return (self.to_s.empty? ? '' : self.to_s.unpack('H' + (self.to_s.bytesize*2).to_s)[0]) end |
#data_to_i ⇒ Object
Returns the data converted from hexidecimal into an integer. This is usually as a BigInt.
50 51 52 |
# File 'lib/securize_string/binary_string_data_methods.rb', line 50 def data_to_i return (self.to_s.empty? ? 0 : self.data_to_hex.hex) end |