Class: Detroit::Assembly
Overview
An assembly is a set of production lines where each line is a list of named work stations.
Instance Method Summary collapse
-
#find(station) ⇒ Object
Lookup a chain by a given stage name.
-
#included(tool_class) ⇒ void
When the tool chain is included into a class, register that class as a tool.
-
#initialize(name, &block) ⇒ Assembly
constructor
A new instance of Assembly.
-
#line(*stations) ⇒ Object
Define a chain of named links.
-
#lines ⇒ Array<Array<Symbol>>
Returns a list of lists of stops.
-
#register_tool(tool_class) ⇒ Class
Add tool to toolchain.
Constructor Details
#initialize(name, &block) ⇒ Assembly
Returns a new instance of Assembly.
24 25 26 27 28 29 30 31 |
# File 'lib/detroit/assembly.rb', line 24 def initialize(name, &block) Detroit.assemblies[name.to_s.downcase.to_sym] = self @lines = [] @tools = [] super(&block) #module_eval(&block) end |
Instance Method Details
#find(station) ⇒ Object
Lookup a chain by a given stage name.
49 50 51 52 53 54 55 |
# File 'lib/detroit/assembly.rb', line 49 def find(station) station = station.to_sym lines.find do |line| line.include?(station) end end |
#included(tool_class) ⇒ void
This method returns an undefined value.
When the tool chain is included into a class, register that class as a tool.
70 71 72 |
# File 'lib/detroit/assembly.rb', line 70 def included(tool_class) register_tool(tool_class) unless @tools.include?(tool_class) end |
#line(*stations) ⇒ Object
Define a chain of named links.
41 42 43 44 |
# File 'lib/detroit/assembly.rb', line 41 def line(*stations) # TODO: raise error if stage already used ? self.lines << stations.map{ |s| s.to_sym } end |
#lines ⇒ Array<Array<Symbol>>
Returns a list of lists of stops.
36 37 38 |
# File 'lib/detroit/assembly.rb', line 36 def lines @lines end |
#register_tool(tool_class) ⇒ Class
Add tool to toolchain.
60 61 62 63 64 |
# File 'lib/detroit/assembly.rb', line 60 def register_tool(tool_class) tool_class.assembly = self @tools << tool_class Detroit.register_tool(tool_class) end |