class Baikal::Hexdump::Field::Data
The Data
field outputs data on a hexdump row, formatted using a supplied Proc
instance. grouping_rules
are specified as pairs of group size and separator. All group sizes are processed in parallel. In group boundaries where multiple grouping rules would match, only the leftmost one is used.
Public Class Methods
new(formatter, *grouping_rules)
click to toggle source
Calls superclass method
# File lib/baikal/hexdump.rb, line 104 def initialize formatter, *grouping_rules super() @formatter = formatter @grouping_rules = grouping_rules return end
Public Instance Methods
format(row)
click to toggle source
# File lib/baikal/hexdump.rb, line 111 def format row output = "" (0 ... row.expected_size).each do |column| if column != 0 then rule = @grouping_rules.detect{|divisor, separator| column % divisor == 0} output << rule[1] if rule end output << @formatter.call(row.data[column]) end return output end