class String

Some patches that extend the default Ruby String class with some useful methods.

Public Instance Methods

from_hex_str() click to toggle source
# File lib/nxt/patches/string.rb, line 15
def from_hex_str
  unpack('C*')
end
to_hex_str() click to toggle source

Convert the given string to a hexadecimal representation of the same data. This method is non-destructive, it will return a new copy of the string convered to hex.

# File lib/nxt/patches/string.rb, line 9
def to_hex_str
  str = ''
  each_byte { |b| str << format('0x%02x ', b) }
  str
end