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 Return true if there’s a match, false if not.
-
#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.
9 10 11 12 13 14 |
# File 'lib/rsmp/collect/filter.rb', line 9 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.
7 8 9 |
# File 'lib/rsmp/collect/filter.rb', line 7 def component @component end |
#ingoing ⇒ Object (readonly)
Returns the value of attribute ingoing.
7 8 9 |
# File 'lib/rsmp/collect/filter.rb', line 7 def ingoing @ingoing end |
#outgoing ⇒ Object (readonly)
Returns the value of attribute outgoing.
7 8 9 |
# File 'lib/rsmp/collect/filter.rb', line 7 def outgoing @outgoing end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
7 8 9 |
# File 'lib/rsmp/collect/filter.rb', line 7 def type @type end |
Instance Method Details
#accept?(message) ⇒ Boolean
Check a message against our match criteria Return true if there’s a match, false if not
18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/rsmp/collect/filter.rb', line 18 def accept? return false if .direction == :in && @ingoing == false return false if .direction == :out && @outgoing == false if @type unless .is_a?(MessageNotAck) return false unless @type.include? .type end end if @component return false if .attributes['cId'] && .attributes['cId'] != @component end true end |
#reject?(message) ⇒ Boolean
32 33 34 |
# File 'lib/rsmp/collect/filter.rb', line 32 def reject? !accept?() end |