Class: RakeCommandFilter::LineFilter

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

Overview

method for filtering a single line of output from a command

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id, pattern, block) ⇒ LineFilter

Do not call this directly, use CommandDefinition#add_filter



7
8
9
10
11
# File 'lib/line_filter.rb', line 7

def initialize(id, pattern, block)
  @id = id
  @pattern = pattern
  @block = block
end

Instance Attribute Details

#idObject

Returns the value of attribute id.



4
5
6
# File 'lib/line_filter.rb', line 4

def id
  @id
end

#patternObject

Returns the value of attribute pattern.



4
5
6
# File 'lib/line_filter.rb', line 4

def pattern
  @pattern
end

Instance Method Details

#match(source) ⇒ LineFilterResult

Called to determine if this filter matches a line. If it does, returns the result from the block defined with CommandDefinition#add_filter.

Returns:



17
18
19
20
21
22
# File 'lib/line_filter.rb', line 17

def match(source)
  source.scan(@pattern) do |matches|
    return @block.call(matches)
  end
  return nil
end