Class: ClassMetrix::Formatters::Components::GenericHeaderComponent

Inherits:
Base::BaseComponent show all
Defined in:
lib/class_metrix/formatters/components/generic_header_component.rb

Instance Attribute Summary

Attributes inherited from Base::BaseComponent

#data, #options, #value_processor

Instance Method Summary collapse

Constructor Details

#initialize(data, options = {}) ⇒ GenericHeaderComponent

Returns a new instance of GenericHeaderComponent.



9
10
11
12
13
14
15
# File 'lib/class_metrix/formatters/components/generic_header_component.rb', line 9

def initialize(data, options = {})
  super
  @format = options.fetch(:format, :markdown)
  @title = options[:title]
  @extraction_types = options[:extraction_types] || []
  @show_metadata = options.fetch(:show_metadata, true)
end

Instance Method Details

#generateObject



17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/class_metrix/formatters/components/generic_header_component.rb', line 17

def generate
  return [] unless @show_metadata

  case @format
  when :markdown
    generate_markdown_header
  when :csv
    generate_csv_header
  else
    raise ArgumentError, "Unknown format: #{@format}"
  end
end