Class: StringLineHexdumper
Overview
Dump a line of text as hex dump.
- Author
-
Peter Kofler
Constant Summary collapse
- NIBBLE_SIZE =
Each displayed number is 2 nibbles, i.e. it’s a byte.
2
- NIBBLE_FORMAT_STR =
"%#{NIBBLE_SIZE}.#{NIBBLE_SIZE}X "
- NIBBLE_WHITE_SPACE =
' ' * (NIBBLE_SIZE + 1)
Class Method Summary collapse
-
.empty(columns) ⇒ Object
Factory method to create a formatter for an empty line with columns length.
Instance Method Summary collapse
- #format ⇒ Object
-
#initialize(address, columns, data) ⇒ StringLineHexdumper
constructor
A new instance of StringLineHexdumper.
Constructor Details
#initialize(address, columns, data) ⇒ StringLineHexdumper
Returns a new instance of StringLineHexdumper.
37 38 39 40 41 |
# File 'lib/javaclass/string_hexdump.rb', line 37 def initialize(address, columns, data) @address = address @maxlen = columns @data = data end |
Class Method Details
.empty(columns) ⇒ Object
Factory method to create a formatter for an empty line with columns length.
33 34 35 |
# File 'lib/javaclass/string_hexdump.rb', line 33 def self.empty(columns) StringLineHexdumper.new(0, columns, '') end |
Instance Method Details
#format ⇒ Object
43 44 45 46 47 48 49 50 |
# File 'lib/javaclass/string_hexdump.rb', line 43 def format address = format_address hexbytes = format_bytes space = add_whitespace display = strip_non_printable "#{address}: #{hexbytes.join}#{space}; #{display}\n" end |