Class: RedShift::Component::Port
Instance Attribute Summary collapse
-
#component ⇒ Object
readonly
Returns the value of attribute component.
-
#connectable ⇒ Object
readonly
Returns the value of attribute connectable.
-
#variable ⇒ Object
readonly
Returns the value of attribute variable.
Instance Method Summary collapse
- #<<(other) ⇒ Object
- #>>(other) ⇒ Object
- #_connect(port) ⇒ Object
- #check_connectable ⇒ Object
- #connect(port) ⇒ Object
- #disconnect ⇒ Object
-
#initialize(component, variable, connectable) ⇒ Port
constructor
A new instance of Port.
-
#source ⇒ Object
Convenience method to get source port rather than component/var pair.
- #source_component ⇒ Object
- #source_variable ⇒ Object
- #value ⇒ Object
Constructor Details
#initialize(component, variable, connectable) ⇒ Port
Returns a new instance of Port.
5 6 7 |
# File 'lib/redshift/port.rb', line 5 def initialize component, variable, connectable @component, @variable, @connectable = component, variable, connectable end |
Instance Attribute Details
#component ⇒ Object (readonly)
Returns the value of attribute component.
3 4 5 |
# File 'lib/redshift/port.rb', line 3 def component @component end |
#connectable ⇒ Object (readonly)
Returns the value of attribute connectable.
3 4 5 |
# File 'lib/redshift/port.rb', line 3 def connectable @connectable end |
#variable ⇒ Object (readonly)
Returns the value of attribute variable.
3 4 5 |
# File 'lib/redshift/port.rb', line 3 def variable @variable end |
Instance Method Details
#<<(other) ⇒ Object
29 30 31 32 |
# File 'lib/redshift/port.rb', line 29 def <<(other) connect(other) return other end |
#>>(other) ⇒ Object
34 35 36 37 |
# File 'lib/redshift/port.rb', line 34 def >>(other) other.connect(self) return other end |
#_connect(port) ⇒ Object
25 26 27 |
# File 'lib/redshift/port.rb', line 25 def _connect port component.connect(variable, port && port.component, port && port.variable, false) end |
#check_connectable ⇒ Object
14 15 16 17 18 |
# File 'lib/redshift/port.rb', line 14 def check_connectable unless connectable raise TypeError, "Not an input: #{variable} in #{component.class}" end end |
#connect(port) ⇒ Object
20 21 22 23 |
# File 'lib/redshift/port.rb', line 20 def connect port check_connectable component.connect(variable, port && port.component, port && port.variable) end |
#disconnect ⇒ Object
39 40 41 |
# File 'lib/redshift/port.rb', line 39 def disconnect connect nil end |
#source ⇒ Object
Convenience method to get source port rather than component/var pair.
10 11 12 |
# File 'lib/redshift/port.rb', line 10 def source source_component && source_component.port(source_variable) end |
#source_component ⇒ Object
43 44 45 46 |
# File 'lib/redshift/port.rb', line 43 def source_component check_connectable component.source_component_for(variable) end |
#source_variable ⇒ Object
48 49 50 51 |
# File 'lib/redshift/port.rb', line 48 def source_variable check_connectable component.source_variable_for(variable) end |
#value ⇒ Object
53 54 55 |
# File 'lib/redshift/port.rb', line 53 def value component.send variable end |