Class: Wukong::Processor::Filter

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

Overview

A widget which filters input records according to some criterion.

Direct Known Subclasses

Head, Identity, Limit, Null, RegexpFilter, Reject, Sample, Select, Tail

Constant Summary

Constants inherited from Wukong::Processor

SerializerError

Instance Method Summary collapse

Methods inherited from Wukong::Processor

configure, consumes, description, #expected_record_type, #expected_serialization, #finalize, #perform_action, 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

#process(record) {|record| ... } ⇒ Object

Process a record by yielding it only if it should be selected by this filter.

Parameters:

  • record (Object)

    an input record

Yields:

  • (record)

    yielded if this record should pass the filter

Yield Parameters:

  • record (Object)

See Also:



20
21
22
# File 'lib/wukong/widget/filters.rb', line 20

def process(record)
  yield(record) if select?(record)
end

#reject?(record) ⇒ true, false

Should the given record be rejected by this filter?

Parameters:

  • record (Object)

Returns:

  • (true, false)

See Also:



38
39
40
# File 'lib/wukong/widget/filters.rb', line 38

def reject?(record)
  not select?(record)
end

#select?(record) ⇒ true, false

Should the given record be passed by this filter?

Parameters:

  • record (Object)

Returns:

  • (true, false)

See Also:



29
30
31
# File 'lib/wukong/widget/filters.rb', line 29

def select?(record)
  true
end