Class: Lf::Filter::Regexp

Inherits:
Lf::Filter show all
Defined in:
lib/lf/filter/regexp.rb

Constant Summary

Constants inherited from Lf::Filter

FILTERS

Instance Method Summary collapse

Methods inherited from Lf::Filter

[], []=, filter_alias, inherited, parse

Constructor Details

#initialize(arg) ⇒ Regexp

Returns a new instance of Regexp.



4
5
6
7
# File 'lib/lf/filter/regexp.rb', line 4

def initialize(arg)
  @label, @value = *arg.split(':')
  @value = ::Regexp.new(@value)
end

Instance Method Details

#apply(row) ⇒ Object



9
10
11
# File 'lib/lf/filter/regexp.rb', line 9

def apply(row)
  row[@label.to_s.to_sym].match(@value) ? row : nil
end