Class: String

Inherits:
Object
  • Object
show all
Defined in:
lib/nxt/patches/string.rb

Instance Method Summary collapse

Instance Method Details

#from_hex_strObject



19
20
21
22
23
24
25
26
27
28
# File 'lib/nxt/patches/string.rb', line 19

def from_hex_str
  data = self.split(' ')
  str = ''

  data.each do |h|
    str += '%c' % h
  end

  str
end

#from_hex_str_twoObject



12
13
14
15
16
17
# File 'lib/nxt/patches/string.rb', line 12

def from_hex_str_two
  data = self.split(' ')
  str = ''
  data.each {|h| eval "str += '%c' % #{h}"}
  str
end

#to_hex_strObject

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.



5
6
7
8
9
# File 'lib/nxt/patches/string.rb', line 5

def to_hex_str
  str = ''
  self.each_byte {|b| str << '0x%02x ' % b}
  str
end