Class: Detroit::Toolchain::Worker
- Defined in:
- lib/detroit/toolchain/worker.rb
Overview
Service class wraps a Tool instance when it is made part of an assembly.
TODO: Perhpas a better name would be ‘Link`, as in “chain link”?
Instance Attribute Summary collapse
-
#active ⇒ Object
Returns the value of attribute active.
-
#key ⇒ Object
readonly
Returns the value of attribute key.
-
#priority ⇒ Object
Returns the value of attribute priority.
-
#tool ⇒ Object
readonly
Returns the value of attribute tool.
-
#track ⇒ Object
Returns the value of attribute track.
Instance Method Summary collapse
-
#initialize(key, tool_class, options) ⇒ Worker
constructor
Create new wrapper.
- #inspect ⇒ Object
-
#invoke(station, stop = nil) ⇒ Object
Run the service assembly station procedure.
-
#stop?(station, stop = nil) ⇒ Boolean, Symbol
Does the tool handle the given assembly station?.
Constructor Details
#initialize(key, tool_class, options) ⇒ Worker
Create new wrapper.
41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/detroit/toolchain/worker.rb', line 41 def initialize(key, tool_class, ) @key = key ## set defaults @track = nil @priority = 0 @active = true self.active = .delete('active') if !['active'].nil? self.track = .delete('track') if .key?('track') self.priority = .delete('priority') if .key?('priority') @tool = tool_class.new() end |
Instance Attribute Details
#active ⇒ Object
Returns the value of attribute active.
17 18 19 |
# File 'lib/detroit/toolchain/worker.rb', line 17 def active @active end |
#key ⇒ Object (readonly)
Returns the value of attribute key.
14 15 16 |
# File 'lib/detroit/toolchain/worker.rb', line 14 def key @key end |
#priority ⇒ Object
Returns the value of attribute priority.
16 17 18 |
# File 'lib/detroit/toolchain/worker.rb', line 16 def priority @priority end |
#tool ⇒ Object (readonly)
Returns the value of attribute tool.
18 19 20 |
# File 'lib/detroit/toolchain/worker.rb', line 18 def tool @tool end |
#track ⇒ Object
Returns the value of attribute track.
15 16 17 |
# File 'lib/detroit/toolchain/worker.rb', line 15 def track @track end |
Instance Method Details
#inspect ⇒ Object
76 77 78 |
# File 'lib/detroit/toolchain/worker.rb', line 76 def inspect "<#{self.class}:#{object_id} @key='#{key}'>" end |
#invoke(station, stop = nil) ⇒ Object
Run the service assembly station procedure.
71 72 73 |
# File 'lib/detroit/toolchain/worker.rb', line 71 def invoke(station, stop=nil) @tool.assemble(station.to_sym, :destination=>stop.to_sym) end |
#stop?(station, stop = nil) ⇒ Boolean, Symbol
Does the tool handle the given assembly station?
If ‘true` is returned than the station is handled by a method in the tool with the same name.
If a symbol is returned then the station is handled, but via the method named by the returned symbol.
65 66 67 |
# File 'lib/detroit/toolchain/worker.rb', line 65 def stop?(station, stop=nil) @tool.assemble?(station.to_sym, :destination=>stop.to_sym) end |