Class: Contrek::Concurrent::Position
- Inherits:
-
Object
- Object
- Contrek::Concurrent::Position
- Includes:
- Listable
- Defined in:
- lib/contrek/finder/concurrent/position.rb
Instance Attribute Summary collapse
-
#end_point ⇒ Object
readonly
Returns the value of attribute end_point.
Attributes included from Listable
Instance Method Summary collapse
- #after_add(new_queue) ⇒ Object
- #before_rem(old_queue) ⇒ Object
-
#initialize(hub:, position:, known_endpoint: nil) ⇒ Position
constructor
A new instance of Position.
- #inspect ⇒ Object
- #payload ⇒ Object
Constructor Details
#initialize(hub:, position:, known_endpoint: nil) ⇒ Position
Returns a new instance of Position.
8 9 10 11 12 13 14 15 16 |
# File 'lib/contrek/finder/concurrent/position.rb', line 8 def initialize(hub:, position:, known_endpoint: nil) if !known_endpoint.nil? @end_point = known_endpoint @position = @end_point.position else @end_point = hub.payloads[position[:y]] ||= EndPoint.new(position) if hub @position = position end end |
Instance Attribute Details
#end_point ⇒ Object (readonly)
Returns the value of attribute end_point.
6 7 8 |
# File 'lib/contrek/finder/concurrent/position.rb', line 6 def end_point @end_point end |
Instance Method Details
#after_add(new_queue) ⇒ Object
22 23 24 |
# File 'lib/contrek/finder/concurrent/position.rb', line 22 def after_add(new_queue) @end_point.queues << new_queue if @end_point end |
#before_rem(old_queue) ⇒ Object
26 27 28 |
# File 'lib/contrek/finder/concurrent/position.rb', line 26 def before_rem(old_queue) @end_point&.queues&.delete(old_queue) end |
#inspect ⇒ Object
30 31 32 |
# File 'lib/contrek/finder/concurrent/position.rb', line 30 def inspect "#{self.class} (#{payload})" end |
#payload ⇒ Object
18 19 20 |
# File 'lib/contrek/finder/concurrent/position.rb', line 18 def payload @position end |