Class: Dor::Workflow::Graph::Process
- Inherits:
-
Object
- Object
- Dor::Workflow::Graph::Process
- Defined in:
- lib/dor/workflow/graph.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#node ⇒ Object
readonly
Returns the value of attribute node.
-
#prerequisites ⇒ Object
readonly
Returns the value of attribute prerequisites.
-
#status ⇒ Object
Returns the value of attribute status.
Instance Method Summary collapse
- #all_prerequisites ⇒ Object
- #depends_on(*processes) ⇒ Object
- #id ⇒ Object
-
#initialize(graph, id, name) ⇒ Process
constructor
A new instance of Process.
- #same_as(process) ⇒ Object
- #set_status(s) ⇒ Object
Constructor Details
#initialize(graph, id, name) ⇒ Process
Returns a new instance of Process.
106 107 108 109 110 111 112 113 114 |
# File 'lib/dor/workflow/graph.rb', line 106 def initialize(graph, id, name) @name = name @graph = graph @node = @graph.add_nodes(id) @node.shape = 'box' @node.label = name @prerequisites = [] self.set_status('unknown') end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
104 105 106 |
# File 'lib/dor/workflow/graph.rb', line 104 def name @name end |
#node ⇒ Object (readonly)
Returns the value of attribute node.
104 105 106 |
# File 'lib/dor/workflow/graph.rb', line 104 def node @node end |
#prerequisites ⇒ Object (readonly)
Returns the value of attribute prerequisites.
104 105 106 |
# File 'lib/dor/workflow/graph.rb', line 104 def prerequisites @prerequisites end |
#status ⇒ Object
Returns the value of attribute status.
104 105 106 |
# File 'lib/dor/workflow/graph.rb', line 104 def status @status end |
Instance Method Details
#all_prerequisites ⇒ Object
158 159 160 |
# File 'lib/dor/workflow/graph.rb', line 158 def all_prerequisites prerequisites.collect { |p| p.all_prerequisites + [p.name] }.flatten.uniq end |
#depends_on(*processes) ⇒ Object
138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 |
# File 'lib/dor/workflow/graph.rb', line 138 def depends_on(*processes) wf1 = self.id.split(/:/)[0..1].join(':') processes.each { |process| wf2 = process.id.split(/:/)[0..1].join(':') edge = (process.node << @node) edge.dir = 'both' edge.arrowhead = 'none' edge.arrowtail = 'none' if (wf1 != wf2) edge.style = 'dashed' end self.prerequisites << process } return self end |
#id ⇒ Object
116 117 118 |
# File 'lib/dor/workflow/graph.rb', line 116 def id @node.id end |
#same_as(process) ⇒ Object
154 155 156 |
# File 'lib/dor/workflow/graph.rb', line 154 def same_as(process) @node = process.node end |
#set_status(s) ⇒ Object
133 134 135 136 |
# File 'lib/dor/workflow/graph.rb', line 133 def set_status(s) self.status = s return self end |