Class: String

Inherits:
Object
  • Object
show all
Defined in:
lib/rubydns/extensions/string.rb,
lib/rubydns/extensions/hexdump.rb,
lib/rubydns/extensions/string-1.8.rb,
lib/rubydns/extensions/string-1.9.2.rb

Instance Method Summary collapse

Instance Method Details

#bytesizeObject



24
25
26
# File 'lib/rubydns/extensions/string-1.8.rb', line 24

def bytesize
	size
end

#byteslice(*args) ⇒ Object



28
29
30
# File 'lib/rubydns/extensions/string-1.8.rb', line 28

def byteslice(*args)
	self[*args]
end

#chunked(chunk_size = 255) ⇒ Object



24
25
26
# File 'lib/rubydns/extensions/string.rb', line 24

def chunked(chunk_size = 255)
	RubyDNS::chunked(self)
end

#hexdumpObject



24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/rubydns/extensions/hexdump.rb', line 24

def hexdump
	i = 1
	out = StringIO.new
	
	out.puts "Size: #{self.bytesize}"
	while (self.length > 16*(i-1))
		a = self.slice(16*(i-1)..(16*i)-1)
		out.printf("%06x: %4.4x %4.4x %4.4x %4.4x   %4.4x %4.4x %4.4x %4.4x ", (i-1)*16,  *a.unpack("n16"))
		out.printf("|%s|\n", a.tr("^\040-\176","."))
		i += 1
	end
	
	return out.string
end