Class: SPNet::SignalInPort
- Includes:
- Hashmake::HashMakeable
- Defined in:
- lib/spnet/ports/signal_in_port.rb
Overview
Recieves signal input for processing in a Block object.
Constant Summary collapse
- ARG_SPECS =
Define arg specs to use in processing hashed arguments during #initialize.
{ :limiter => arg_spec(:reqd => false, :type => Limiter, :default => ->(){ NoLimiter.new }, :validator => ->(a){ !a.is_a?(EnumLimiter) }), }
Instance Attribute Summary collapse
-
#limiter ⇒ Object
readonly
Returns the value of attribute limiter.
-
#queue ⇒ Object
readonly
Returns the value of attribute queue.
Attributes inherited from InPort
Instance Method Summary collapse
-
#dequeue_values(count = @queue.count) ⇒ Object
Remove values to queue.
-
#enqueue_values(values) ⇒ Object
Add values to queue.
-
#initialize(hashed_args = {}) ⇒ SignalInPort
constructor
A new instance of SignalInPort.
Methods inherited from InPort
#clear_link, #linked?, #set_link
Constructor Details
#initialize(hashed_args = {}) ⇒ SignalInPort
A new instance of SignalInPort.
20 21 22 23 24 25 26 27 |
# File 'lib/spnet/ports/signal_in_port.rb', line 20 def initialize hashed_args = {} hash_make hashed_args, SignalInPort::ARG_SPECS @queue = [] @skip_limiting = @limiter.is_a?(NoLimiter) super(:matching_class => SignalOutPort) end |
Instance Attribute Details
#limiter ⇒ Object (readonly)
Returns the value of attribute limiter.
15 16 17 |
# File 'lib/spnet/ports/signal_in_port.rb', line 15 def limiter @limiter end |
#queue ⇒ Object (readonly)
Returns the value of attribute queue.
15 16 17 |
# File 'lib/spnet/ports/signal_in_port.rb', line 15 def queue @queue end |
Instance Method Details
#dequeue_values(count = @queue.count) ⇒ Object
Remove values to queue.
42 43 44 45 |
# File 'lib/spnet/ports/signal_in_port.rb', line 42 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) ⇒ Object
Add values to queue.
30 31 32 33 34 35 36 37 38 |
# File 'lib/spnet/ports/signal_in_port.rb', line 30 def enqueue_values values unless @skip_limiting for i in 0...values.count values[i] = @limiter.apply_limit values[i] end end @queue.concat values end |