Class: Port

Inherits:
Object
  • Object
show all
Defined in:
lib/Port.rb

Overview

This class defines the Port object. Ports are instantiated each time an Inst object is created and they correspond to the conecptual “ports” found on each Inst. They are connected to other ports via a connection list, these connections are built by the Parser component and in sum form the data structure which models the digital circuit described by the input EDF file.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(inst, type, name) ⇒ Port

This method is called each time a new Port object is instantiated. It takes a string argument for the Inst it belongs to (inst); the type of port it is, either input or output, (type); and its name (name), a concatenation of the name of the Inst to which it belongs and the port which it is representing.



12
13
14
15
16
17
# File 'lib/Port.rb', line 12

def initialize(inst, type, name)
  self.inst = inst
  self.connections = []
  self.type = type
  self.name = name
end

Instance Attribute Details

#connectionsObject

Returns the value of attribute connections.



7
8
9
# File 'lib/Port.rb', line 7

def connections
  @connections
end

#instObject

Returns the value of attribute inst.



7
8
9
# File 'lib/Port.rb', line 7

def inst
  @inst
end

#nameObject

Returns the value of attribute name.



7
8
9
# File 'lib/Port.rb', line 7

def name
  @name
end

#typeObject

Returns the value of attribute type.



7
8
9
# File 'lib/Port.rb', line 7

def type
  @type
end

Instance Method Details

#add_connection(port) ⇒ Object

This method takes the name of another port as a string (port) and appends it to an array which holds the connection list attribute (connections) for the given port.



21
22
23
# File 'lib/Port.rb', line 21

def add_connection(port)
  self.connections << port
end