Class: RFlow::Component::HashSubPort

Inherits:
Object
  • Object
show all
Defined in:
lib/rflow/component/port.rb

Overview

Represents a keyed subport on a RFlow::Component - that is, an input or output port that has been subscripted with a port name for subdividing the messages being received or output.

Instance Method Summary collapse

Constructor Details

#initialize(hash_port, key) ⇒ HashSubPort

Returns a new instance of HashSubPort.

Parameters:

  • hash_port (HashPort)

    the port to which this subport belongs

  • key (String)

    the key subscript



75
76
77
78
# File 'lib/rflow/component/port.rb', line 75

def initialize(hash_port, key)
  @hash_port = hash_port
  @key = key
end

Instance Method Details

#connectionsArray<Connection>

Retrieve all the connections for this subport.

Returns:



89
90
91
# File 'lib/rflow/component/port.rb', line 89

def connections
  @hash_port.connections_for(@key)
end

#direct_connect(other_port) ⇒ void

This method returns an undefined value.

Directly connect this subport to another port.

Parameters:

  • other_port (Port)

    the other port to connect to



96
97
98
# File 'lib/rflow/component/port.rb', line 96

def direct_connect(other_port)
  @hash_port.direct_connect(@key, other_port)
end

#eachArray<Connection>

Enumerate the connections to this subport, yielding each.

Returns:



102
103
104
# File 'lib/rflow/component/port.rb', line 102

def each
  connections.each {|connection| yield connection }
end

#send_message(message) ⇒ void

This method returns an undefined value.

Send a Message down all the connections to this subport.

Parameters:



83
84
85
# File 'lib/rflow/component/port.rb', line 83

def send_message(message)
  connections.each {|connection| connection.send_message(message) }
end