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 Method Summary collapse

Methods inherited from Filter

#process, #reject?

Methods inherited from Wukong::Processor

configure, consumes, description, #expected_record_type, #expected_serialization, #finalize, #perform_action, #process, produces, #receive_action, #setup, #stop, valid_serializer?, validate_and_set_serialization

Methods included from Logging

included

Methods included from Hanuman::StageClassMethods

#builder, #label, #register, #set_builder

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