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

Instance Method Details

#data_to_hexObject

Returns the hexidecimal string representation of the data.



48
49
50
# File 'lib/securize_string/binary_string_data_methods.rb', line 48

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_iObject

Returns the data converted from hexidecimal into an integer. This is usually as a BigInt.



55
56
57
# File 'lib/securize_string/binary_string_data_methods.rb', line 55

def data_to_i
  return (self.to_s.empty? ? 0 : self.data_to_hex.hex)
end