Class: RakeCommandFilter::LineFilter
- Inherits:
-
Object
- Object
- RakeCommandFilter::LineFilter
- Defined in:
- lib/line_filter.rb
Overview
method for filtering a single line of output from a command
Instance Attribute Summary collapse
-
#id ⇒ Object
Returns the value of attribute id.
-
#pattern ⇒ Object
Returns the value of attribute pattern.
Instance Method Summary collapse
-
#initialize(id, pattern, block) ⇒ LineFilter
constructor
Do not call this directly, use CommandDefinition#add_filter.
-
#match(source) ⇒ LineFilterResult
Called to determine if this filter matches a line.
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
#id ⇒ Object
Returns the value of attribute id.
4 5 6 |
# File 'lib/line_filter.rb', line 4 def id @id end |
#pattern ⇒ Object
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.
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 |