Class: SPNet::InPort

Inherits:
Object
  • Object
show all
Includes:
Hashmake::HashMakeable
Defined in:
lib/spnet/core/in_port.rb

Overview

A port that exposes some functionality in a block.

Author:

  • James Tunnell

Direct Known Subclasses

CommandInPort, ParamInPort, SignalInPort

Constant Summary collapse

ARG_SPECS =

Define ArgSpec’s to use in processing hashed arguments during #initialize.

{
  :matching_class => arg_spec(:reqd => true, :type => Class),
}

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args) ⇒ InPort

A new instance of InPort.

Parameters:

  • args (Hash)

    Hashed arguments for initialization. See InPort::ARG_SPECS for details.



19
20
21
22
# File 'lib/spnet/core/in_port.rb', line 19

def initialize args
  hash_make args, InPort::ARG_SPECS
  @link = nil
end

Instance Attribute Details

Returns the value of attribute link.



14
15
16
# File 'lib/spnet/core/in_port.rb', line 14

def link
  @link
end

#matching_classObject (readonly)

Returns the value of attribute matching_class.



14
15
16
# File 'lib/spnet/core/in_port.rb', line 14

def matching_class
  @matching_class
end

Instance Method Details

Set @link to nil.



31
32
33
# File 'lib/spnet/core/in_port.rb', line 31

def clear_link
  @link = nil
end

#linked?Boolean

Return true if @link is not nil.

Returns:

  • (Boolean)


36
37
38
# File 'lib/spnet/core/in_port.rb', line 36

def linked?
  !link.nil?
end

Set @link to the given Link object.

Raises:

  • (ArgumentError)


25
26
27
28
# File 'lib/spnet/core/in_port.rb', line 25

def set_link link
  raise ArgumentError, "link 'to' port is not self" unless link.to == self
  @link = link
end