Module: Myclear::Utils

Defined in:
lib/myclear/utils.rb

Class Method Summary collapse

Class Method Details

.binary_to_hex(str) ⇒ Object



11
12
13
# File 'lib/myclear/utils.rb', line 11

def self.binary_to_hex(str)
  str.unpack("H*").first.upcase
end

.hex_to_binary(str) ⇒ Object



15
16
17
# File 'lib/myclear/utils.rb', line 15

def self.hex_to_binary(str)
  [str.downcase].pack("H*")
end

.stringify_keys(hash) ⇒ Object



3
4
5
6
7
8
9
# File 'lib/myclear/utils.rb', line 3

def self.stringify_keys(hash)
  new_hash = {}
  hash.each do |key, value|
    new_hash[(key.to_s rescue key) || key] = value
  end
  new_hash
end