Class: RSMP::Filter
- Inherits:
-
Object
- Object
- RSMP::Filter
- Defined in:
- lib/rsmp/collect/filter.rb
Overview
Filter messages based on type, direction and component id. Used by Collectors.
Instance Attribute Summary collapse
-
#component ⇒ Object
readonly
Returns the value of attribute component.
-
#ingoing ⇒ Object
readonly
Returns the value of attribute ingoing.
-
#outgoing ⇒ Object
readonly
Returns the value of attribute outgoing.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
-
#accept?(message) ⇒ Boolean
Check a message against our match criteria.
-
#initialize(ingoing: true, outgoing: true, type: nil, component: nil) ⇒ Filter
constructor
A new instance of Filter.
- #reject?(message) ⇒ Boolean
Constructor Details
#initialize(ingoing: true, outgoing: true, type: nil, component: nil) ⇒ Filter
Returns a new instance of Filter.
7 8 9 10 11 12 |
# File 'lib/rsmp/collect/filter.rb', line 7 def initialize(ingoing: true, outgoing: true, type: nil, component: nil) @ingoing = ingoing @outgoing = outgoing @type = type ? [type].flatten : nil @component = component end |
Instance Attribute Details
#component ⇒ Object (readonly)
Returns the value of attribute component.
5 6 7 |
# File 'lib/rsmp/collect/filter.rb', line 5 def component @component end |
#ingoing ⇒ Object (readonly)
Returns the value of attribute ingoing.
5 6 7 |
# File 'lib/rsmp/collect/filter.rb', line 5 def ingoing @ingoing end |
#outgoing ⇒ Object (readonly)
Returns the value of attribute outgoing.
5 6 7 |
# File 'lib/rsmp/collect/filter.rb', line 5 def outgoing @outgoing end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
5 6 7 |
# File 'lib/rsmp/collect/filter.rb', line 5 def type @type end |
Instance Method Details
#accept?(message) ⇒ Boolean
Check a message against our match criteria
15 16 17 18 19 20 21 |
# File 'lib/rsmp/collect/filter.rb', line 15 def accept?() return false unless direction_matches?() return false unless type_matches?() return false unless component_matches?() true end |
#reject?(message) ⇒ Boolean
48 49 50 |
# File 'lib/rsmp/collect/filter.rb', line 48 def reject?() !accept?() end |