Class: Detroit::Assembly

Inherits:
Module
  • Object
show all
Defined in:
lib/detroit/assembly.rb

Overview

An assembly is a set of production lines where each line is a list of named work stations.

Instance Method Summary collapse

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.

Returns:

  • nothing.



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

#linesArray<Array<Symbol>>

Returns a list of lists of stops.

Returns:



36
37
38
# File 'lib/detroit/assembly.rb', line 36

def lines
  @lines
end

#register_tool(tool_class) ⇒ Class

Add tool to toolchain.

Returns:

  • (Class)

    The tool class.



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