lib/fd.rb in fd-0.4.0 vs lib/fd.rb in fd-0.5.0

- old
+ new

@@ -29,21 +29,21 @@ raise ArgumentError, "Line width must be a positive integer, was given '#{line_length}'" unless line_length.is_a?(Integer) && line_length.positive? @line_length = line_length @char_table = {} - @char_table[0] = 'NULL' - @char_table[7] = 'BEL' - @char_table[8] = 'BS' - @char_table[9] = 'TAB' - @char_table[10] = 'LF' - @char_table[11] = 'VT' - @char_table[12] = 'FF' - @char_table[13] = 'CR' - @char_table[16] = 'DEL' - @char_table[27] = 'ESC' - @char_table[32] = '__' + @char_table[0] = '␀' + @char_table[7] = '␇' + @char_table[8] = '␈' + @char_table[9] = '␉' + @char_table[10] = '␊' + @char_table[11] = '␋' + @char_table[12] = '␌' + @char_table[13] = '␍' + @char_table[16] = '␡' + @char_table[27] = '␛' + @char_table[32] = '␠' end # dumps the given file _file_name_ to stdout. def dump(content) raise "Not the expected encoding of UFT-8, got #{content.encoding}" unless content.encoding == Encoding::UTF_8 @@ -93,17 +93,17 @@ end def append_to_line(bytes, char) @byte_count_in_line += bytes.size bytes.each { |bt| @hex_values << format('%02x', bt) } - @line += format('%5s', (char_table[char.ord] || char)) + @line += format('%2s', (char_table[char.ord] || char)) @char_index += 1 end def enough_space_in_line?(byte_count_in_line, bytes) byte_count_in_line + bytes.size <= line_length end def print_single_line - puts("#{format("%#{(3 * line_length) - 1}s", hex_values.join(' '))} |#{format("%#{5 * line_length}s", line)}") + puts("#{format("%#{(3 * line_length) - 1}s", hex_values.join(' '))} |#{format("%#{2 * line_length}s", line)}") end end