Class: SPNet::SignalOutPort
- Defined in:
- lib/spnet/ports/signal_out_port.rb
Overview
Output signal values to a connected SignalInPort object.
Constant Summary
Constants inherited from OutPort
Instance Attribute Summary collapse
-
#queue ⇒ Object
readonly
Returns the value of attribute queue.
Attributes inherited from OutPort
Instance Method Summary collapse
-
#dequeue_values(count = @queue.count) ⇒ Object
Remove values to queue.
-
#enqueue_values(values, autosend = true) ⇒ Object
Add values to queue or send them directly to linked port (if autosend is true).
-
#initialize ⇒ SignalOutPort
constructor
A new instance of SignalOutPort.
Methods inherited from OutPort
#clear_link, #linked?, #set_link
Constructor Details
#initialize ⇒ SignalOutPort
A new instance of SignalOutPort.
11 12 13 14 |
# File 'lib/spnet/ports/signal_out_port.rb', line 11 def initialize @queue = [] super(:matching_class => SignalInPort) end |
Instance Attribute Details
#queue ⇒ Object (readonly)
Returns the value of attribute queue.
8 9 10 |
# File 'lib/spnet/ports/signal_out_port.rb', line 8 def queue @queue end |
Instance Method Details
#dequeue_values(count = @queue.count) ⇒ Object
Remove values to queue.
32 33 34 35 |
# File 'lib/spnet/ports/signal_out_port.rb', line 32 def dequeue_values count = @queue.count raise ArgumentError, "count is greater than @queue.count" if count > @queue.count @queue.slice!(0...count) end |
#enqueue_values(values, autosend = true) ⇒ Object
Add values to queue or send them directly to linked port (if autosend is true).
22 23 24 25 26 27 28 |
# File 'lib/spnet/ports/signal_out_port.rb', line 22 def enqueue_values values, autosend = true if autosend && linked? @link.to.enqueue_values values else @queue.concat values end end |