Class: ClassMetrix::ConstantsExtractor

Inherits:
Object
  • Object
show all
Defined in:
lib/class_metrix/extractors/constants_extractor.rb

Instance Method Summary collapse

Constructor Details

#initialize(classes, filters, handle_errors, options = {}) ⇒ ConstantsExtractor

Returns a new instance of ConstantsExtractor.



8
9
10
11
12
13
14
15
# File 'lib/class_metrix/extractors/constants_extractor.rb', line 8

def initialize(classes, filters, handle_errors, options = {})
  @classes = classes
  @filters = filters
  @handle_errors = handle_errors
  @options = default_options.merge(options)
  @debug_level = @options[:debug_level] || :basic
  @logger = Utils::DebugLogger.new("ConstantsExtractor", @options[:debug_mode], @debug_level)
end

Instance Method Details

#extractObject



17
18
19
20
21
22
23
24
25
26
# File 'lib/class_metrix/extractors/constants_extractor.rb', line 17

def extract
  return { headers: [], rows: [] } if @classes.empty?

  constant_names = get_all_constant_names
  constant_names = apply_filters(constant_names)
  headers = build_headers
  rows = build_rows(constant_names)

  { headers: headers, rows: rows }
end