Class: Rubygrep::Matcher

Inherits:
Object
  • Object
show all
Defined in:
lib/rubygrep/matcher.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(regexp, options = {}) ⇒ Matcher

Returns a new instance of Matcher.



5
6
7
8
# File 'lib/rubygrep/matcher.rb', line 5

def initialize(regexp, options = {})
  @options = options
  @regexp = process_with_options(regexp)
end

Instance Attribute Details

#optionsObject

Returns the value of attribute options.



3
4
5
# File 'lib/rubygrep/matcher.rb', line 3

def options
  @options
end

#regexpObject

Returns the value of attribute regexp.



3
4
5
# File 'lib/rubygrep/matcher.rb', line 3

def regexp
  @regexp
end

Instance Method Details

#matches?(string_data) ⇒ Boolean

Returns:

  • (Boolean)


10
11
12
# File 'lib/rubygrep/matcher.rb', line 10

def matches?(string_data)
  regexp.match(string_data[:str])
end