Class: ClassMetrix::Formatters::Components::HeaderComponent

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

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of HeaderComponent.



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

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

Instance Method Details

#generateObject



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

def generate
  output = [] # : Array[String]

  # Add title
  output.concat(generate_title) if @title || @show_metadata

  # Add classes being analyzed
  output.concat(generate_classes_section) if @show_classes

  # Add extraction types info
  output.concat(generate_extraction_info) if @show_extraction_info && !@extraction_types.empty?

  output
end