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.
105 106 107 108 109 110 111 112 113 |
# File 'lib/dor/workflow/graph.rb', line 105 def initialize(graph, id, name) @name = name @graph = graph @node = @graph.add_nodes(id) @node.shape = 'box' @node.label = name @prerequisites = [] set_status('unknown') end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
103 104 105 |
# File 'lib/dor/workflow/graph.rb', line 103 def name @name end |
#node ⇒ Object (readonly)
Returns the value of attribute node.
103 104 105 |
# File 'lib/dor/workflow/graph.rb', line 103 def node @node end |
#prerequisites ⇒ Object (readonly)
Returns the value of attribute prerequisites.
103 104 105 |
# File 'lib/dor/workflow/graph.rb', line 103 def prerequisites @prerequisites end |
#status ⇒ Object
Returns the value of attribute status.
103 104 105 |
# File 'lib/dor/workflow/graph.rb', line 103 def status @status end |
Instance Method Details
#all_prerequisites ⇒ Object
155 156 157 |
# File 'lib/dor/workflow/graph.rb', line 155 def all_prerequisites prerequisites.collect { |p| p.all_prerequisites + [p.name] }.flatten.uniq end |
#depends_on(*processes) ⇒ Object
137 138 139 140 141 142 143 144 145 146 147 148 149 |
# File 'lib/dor/workflow/graph.rb', line 137 def depends_on(*processes) wf1 = 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' edge.style = 'dashed' if wf1 != wf2 prerequisites << process } self end |
#id ⇒ Object
115 116 117 |
# File 'lib/dor/workflow/graph.rb', line 115 def id @node.id end |
#same_as(process) ⇒ Object
151 152 153 |
# File 'lib/dor/workflow/graph.rb', line 151 def same_as(process) @node = process.node end |
#set_status(s) ⇒ Object
132 133 134 135 |
# File 'lib/dor/workflow/graph.rb', line 132 def set_status(s) self.status = s self end |