Class: LicenseFinder::License::HeaderMatcher

Inherits:
Struct
  • Object
show all
Defined in:
lib/license_finder/license/header_matcher.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#base_matcherObject

Returns the value of attribute base_matcher

Returns:

  • (Object)

    the current value of base_matcher



5
6
7
# File 'lib/license_finder/license/header_matcher.rb', line 5

def base_matcher
  @base_matcher
end

#first_n_linesObject

Returns the value of attribute first_n_lines

Returns:

  • (Object)

    the current value of first_n_lines



5
6
7
# File 'lib/license_finder/license/header_matcher.rb', line 5

def first_n_lines
  @first_n_lines
end

Instance Method Details

#matches_text?(text) ⇒ Boolean

Returns:

  • (Boolean)


6
7
8
9
10
11
12
13
14
# File 'lib/license_finder/license/header_matcher.rb', line 6

def matches_text?(text)
  n = if first_n_lines.nil?
        1
      else
        first_n_lines
      end
  header = text.lines.first(n).join || ''
  base_matcher.matches_text?(header)
end