Class: Wukong::Processor::RegexpFilter

Inherits:
Filter show all
Defined in:
lib/wukong/widget/filters.rb

Overview

A widget which only passes records if they match a regular expression.

Examples:

Passing records which match a given expression on the command-line


$ cat input
apple
banana
cat
$ cat input | wu-local regexp --match='^a'
apple

Passing records which match a given expression in a dataflow


Wukong.dataflow(:uses_regexp) do
  ... | regexp(match: /^a/) | ...
end

See Also:

Direct Known Subclasses

NotRegexpFilter

Constant Summary

Constants inherited from Wukong::Processor

SerializerError

Instance Attribute Summary

Attributes included from Hanuman::StageInstanceMethods

#graph

Instance Method Summary collapse

Methods inherited from Filter

#process, #reject?

Methods inherited from Wukong::Processor

configure, description, #finalize, #perform_action, #process, #receive_action, #setup, #stop

Methods included from Logging

included

Methods inherited from Hanuman::Stage

#clone

Methods included from Hanuman::StageClassMethods

#builder, #label, #register, #set_builder

Methods included from Hanuman::StageInstanceMethods

#add_link, #linkable_name, #root

Instance Method Details

#select?(record) ⇒ true, false

Selects a record only if it matches this widget's match field.

Parameters:

  • record (Object)

Returns:

  • (true, false)


149
150
151
152
# File 'lib/wukong/widget/filters.rb', line 149

def select?(record)
  return true unless match
  match =~ record.to_s
end