Class: Fif::Search

Inherits:
Object
  • Object
show all
Defined in:
lib/fif/search.rb

Instance Method Summary collapse

Constructor Details

#initialize(arguments, options) ⇒ Search

Returns a new instance of Search.



3
4
5
6
7
8
# File 'lib/fif/search.rb', line 3

def initialize(arguments, options)
  @options = options

  @file = Regexp.new(arguments[1], options[:fregex_opts]) if arguments[1]
  @line = Regexp.new("(#{arguments[0]})", options[:regex_opts])
end

Instance Method Details

#file_match(file) ⇒ Object



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

def file_match(file)
  if @file
    @file.match(file)
  else
    true
  end
end

#line_format(line) ⇒ Object



22
23
24
25
26
27
28
# File 'lib/fif/search.rb', line 22

def line_format(line)
  if @options[:colour]
    line.gsub!(@line, '\1'.green)
  else
    line
  end
end

#line_match(line) ⇒ Object



18
19
20
# File 'lib/fif/search.rb', line 18

def line_match(line)
  @line.match(line)
end