Class: CssClassDuplicates::Merger

Inherits:
Object
  • Object
show all
Defined in:
lib/css_class_duplicates/merger.rb

Overview

This class merges found results

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ Merger

Returns a new instance of Merger.



6
7
8
# File 'lib/css_class_duplicates/merger.rb', line 6

def initialize(config)
  @type = config['type']
end

Instance Method Details

#call(entities) ⇒ Object



10
11
12
13
14
15
16
# File 'lib/css_class_duplicates/merger.rb', line 10

def call(entities)
  matches = entities.group_by(&:classes).map do |classes, items|
    Match.new(classes, items.map(&:files).flatten)
  end
  matches = add_partial_matches(matches) if @type == 'partial'
  matches
end