Class: CssClassDuplicates::Scanner

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

Overview

This class scans string and returns all found matches with positions

Constant Summary collapse

NEW_LINE =
/(\r\n|\r|\n)/.freeze

Instance Method Summary collapse

Constructor Details

#initialize(content) ⇒ Scanner

Returns a new instance of Scanner.



10
11
12
# File 'lib/css_class_duplicates/scanner.rb', line 10

def initialize(content)
  @content = content
end

Instance Method Details

#matches(regex) ⇒ Object



14
15
16
17
18
# File 'lib/css_class_duplicates/scanner.rb', line 14

def matches(regex)
  matches_with_positions(regex).map do |match, start_position|
    [match, file_line(start_position)]
  end
end