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.
53 54 55 56 57 |
# File 'lib/javaclass/string_hexdump.rb', line 53 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.
49 50 51 |
# File 'lib/javaclass/string_hexdump.rb', line 49 def self.empty(columns) StringLineHexdumper.new(0, columns, '') end |
Instance Method Details
#format ⇒ Object
59 60 61 62 63 64 65 66 |
# File 'lib/javaclass/string_hexdump.rb', line 59 def format address = format_address hexbytes = format_bytes space = add_whitespace display = strip_non_printable "#{address}: #{hexbytes.join}#{space}; #{display}\n" end |