Class: ClassMetrix::Formatters::Components::TableComponent::RowProcessor

Inherits:
Object
  • Object
show all
Defined in:
lib/class_metrix/formatters/components/table_component/row_processor.rb

Instance Method Summary collapse

Constructor Details

#initialize(data_extractor, options = {}) ⇒ RowProcessor

Returns a new instance of RowProcessor.



10
11
12
13
14
# File 'lib/class_metrix/formatters/components/table_component/row_processor.rb', line 10

def initialize(data_extractor, options = {})
  @data_extractor = data_extractor
  @hide_main_row = options.fetch(:hide_main_row, false)
  @hide_key_rows = options.fetch(:hide_key_rows, true) # Default: show only main rows
end

Instance Method Details

#process_expanded_rows(rows) ⇒ Object



27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/class_metrix/formatters/components/table_component/row_processor.rb', line 27

def process_expanded_rows(rows)
  expanded_rows = [] # : Array[Array[String]]

  rows.each do |row|
    if @data_extractor.row_has_expandable_hash?(row)
      expanded_rows.concat(expand_row(row))
    else
      expanded_rows << process_non_hash_row(row)
    end
  end

  expanded_rows
end

#process_simple_rows(rows) ⇒ Object



16
17
18
19
20
21
22
23
24
25
# File 'lib/class_metrix/formatters/components/table_component/row_processor.rb', line 16

def process_simple_rows(rows)
  rows.map do |row|
    processed_row = [row[0]] # Keep the behavior name as-is
    rest_values = row[1..] || []
    rest_values.each do |value|
      processed_row << ValueProcessor.process(value)
    end
    processed_row
  end
end