Class: Ghaki::Match::Finder

Inherits:
Object
  • Object
show all
Defined in:
lib/ghaki/match/finder.rb

Overview

Match against list of regular expressions.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(arg_rx_list) ⇒ Finder

Given list of regular expressions



10
11
12
# File 'lib/ghaki/match/finder.rb', line 10

def initialize arg_rx_list
  @lookups = arg_rx_list
end

Instance Attribute Details

#lookupsObject

Returns the value of attribute lookups.



7
8
9
# File 'lib/ghaki/match/finder.rb', line 7

def lookups
  @lookups
end

Instance Method Details

#match_lines(lines) ⇒ Object

Matches any line against saved regexps.



23
24
25
26
27
28
# File 'lib/ghaki/match/finder.rb', line 23

def match_lines lines
  lines.each do |text|
    return true if self.match_text( text )
  end
  false
end

#match_text(text) ⇒ Object

Matches string against saved regexps.



15
16
17
18
19
20
# File 'lib/ghaki/match/finder.rb', line 15

def match_text text
  @lookups.each do |rx_curr|
    return true if text =~ rx_curr
  end
  false
end