Class: String

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

Instance Method Summary collapse

Instance Method Details

#to_hexObject



2
3
4
5
6
7
8
9
10
# File 'lib/ext/string.rb', line 2

def to_hex
  bytes.map do |ch|
    if ch.chr.index(/^[a-z_]$/i)
      ch.chr
    else
      '\x%02x' % ch
    end
  end.join('')
end