Class: NoyesFilterDSL::SerialFilter
- Inherits:
-
Object
- Object
- NoyesFilterDSL::SerialFilter
- Defined in:
- lib/common/serial_filter.rb
Instance Attribute Summary collapse
-
#filters ⇒ Object
readonly
Returns the value of attribute filters.
Instance Method Summary collapse
- #&(other) ⇒ Object
- #<<(data) ⇒ Object
-
#initialize(filters = []) ⇒ SerialFilter
constructor
A new instance of SerialFilter.
- #|(other) ⇒ Object
Constructor Details
#initialize(filters = []) ⇒ SerialFilter
Returns a new instance of SerialFilter.
4 5 6 |
# File 'lib/common/serial_filter.rb', line 4 def initialize filters = [] @filters = filters.kind_of?(Array) ? filters : [filters] end |
Instance Attribute Details
#filters ⇒ Object (readonly)
Returns the value of attribute filters.
3 4 5 |
# File 'lib/common/serial_filter.rb', line 3 def filters @filters end |
Instance Method Details
#&(other) ⇒ Object
11 12 13 14 15 16 17 |
# File 'lib/common/serial_filter.rb', line 11 def & other raise "Parameter does not respond to <<." unless other.respond_to? :<< if other.kind_of? SerialFilter return SerialFilter.new(@filters.clone + other.filters.clone) end SerialFilter.new((@filters + [other]).flatten) end |
#<<(data) ⇒ Object
7 8 9 10 |
# File 'lib/common/serial_filter.rb', line 7 def << data @filters.each {|f| data >>= f} data end |
#|(other) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/common/serial_filter.rb', line 18 def | other raise "Parameter does not respond to <<." unless other.respond_to? :<< other_filters = if other.kind_of? Array SerialFilter.new other elsif other.kind_of? ParallelFilter other_filters = other.filters else other end ParallelFilter.new([SerialFilter.new(filters), other_filters]) end |