Class: SPNet::LinkState
- Inherits:
-
Object
- Object
- SPNet::LinkState
- Includes:
- Hashmake::HashMakeable
- Defined in:
- lib/spnet/storage/link_state.rb
Overview
Represent a Link object using only serializeable objects.
Constant Summary collapse
- ARG_SPECS =
Define arg specs to use in processing hashed arguments during #initialize.
{ :from => arg_spec(:reqd => true, :type => PortLocater), :to => arg_spec(:reqd => true, :type => PortLocater) }
Instance Attribute Summary collapse
-
#from ⇒ Object
readonly
Returns the value of attribute from.
-
#to ⇒ Object
readonly
Returns the value of attribute to.
Instance Method Summary collapse
-
#initialize(args) ⇒ LinkState
constructor
A new instance of LinkState.
-
#make_link(blocks) ⇒ Object
Make a Link objet from the current LinkState object.
Constructor Details
Instance Attribute Details
#from ⇒ Object (readonly)
Returns the value of attribute from.
15 16 17 |
# File 'lib/spnet/storage/link_state.rb', line 15 def from @from end |
#to ⇒ Object (readonly)
Returns the value of attribute to.
15 16 17 |
# File 'lib/spnet/storage/link_state.rb', line 15 def to @to end |
Instance Method Details
#make_link(blocks) ⇒ Object
Make a Link objet from the current LinkState object.
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/spnet/storage/link_state.rb', line 22 def make_link blocks raise "from block #{@from.block_name} not found" unless blocks.has_key?(@from.block_name) raise "to block #{@to.block_name} not found" unless blocks.has_key?(@to.block_name) from_block = blocks[@from.block_name] to_block = blocks[@to.block_name] raise "from port #{@from.port_name} not found" unless from_block.out_ports.has_key?(@from.port_name) raise "to port #{@to.port_name} not found" unless to_block.in_ports.has_key?(@to.port_name) from_port = from_block.out_ports[@from.port_name] to_port = to_block.in_ports[@to.port_name] return Link.new(:from => from_port, :to => to_port) end |