Class: Tap::Support::Node

Inherits:
Object show all
Defined in:
lib/tap/support/node.rb

Overview

Represents a task node in a Schema.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(argv = [], input = nil, output = nil) ⇒ Node

Returns a new instance of Node.



21
22
23
24
25
# File 'lib/tap/support/node.rb', line 21

def initialize(argv=[], input=nil, output=nil)
  @argv = argv
  @input = input
  @output = output
end

Instance Attribute Details

#argvObject

An array of arguments used to instantiate the node



9
10
11
# File 'lib/tap/support/node.rb', line 9

def argv
  @argv
end

#inputObject

The input or source for the node. Inputs may be a Join, nil, or an Integer. An Integer input indicates that the node should be enqued to a round using argv as inputs.



15
16
17
# File 'lib/tap/support/node.rb', line 15

def input
  @input
end

#outputObject

The output for the node. Output may be a a Join or nil.



19
20
21
# File 'lib/tap/support/node.rb', line 19

def output
  @output
end

Instance Method Details

#global?Boolean

True if the input and output are nil.

Returns:

  • (Boolean)


34
35
36
# File 'lib/tap/support/node.rb', line 34

def global?
  input == nil && output == nil
end

#globalizeObject

Resets the source and join to nil.



28
29
30
31
# File 'lib/tap/support/node.rb', line 28

def globalize
  self.input = nil
  self.output = nil
end

#inspectObject



50
51
52
# File 'lib/tap/support/node.rb', line 50

def inspect
  "#<#{self.class}:#{object_id} argv=[#{argv.join(' ')}] input=#{input.inspect} output=#{output.inspect}>"
end

#roundObject

Returns the round for self; a round is indicated by an integer input. If input is anything but an integer, round returns nil.



41
42
43
# File 'lib/tap/support/node.rb', line 41

def round
  input.kind_of?(Integer) ? input : nil
end

#round=(input) ⇒ Object

Alias for input=



46
47
48
# File 'lib/tap/support/node.rb', line 46

def round=(input)
  self.input = input
end