Class: Shifty::Gang
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Methods included from Taggable
#criteria=, #criteria_passes?, #has_tag?, #tags=
Constructor Details
#initialize(workers = [], p = {}) ⇒ Gang
Returns a new instance of Gang.
10
11
12
13
14
|
# File 'lib/shifty/gang.rb', line 10
def initialize(workers = [], p = {})
@roster = Roster.new(workers)
self.criteria = p[:criteria]
self.tags = p[:tags]
end
|
Instance Attribute Details
#roster ⇒ Object
Returns the value of attribute roster.
6
7
8
|
# File 'lib/shifty/gang.rb', line 6
def roster
@roster
end
|
Returns the value of attribute tags.
6
7
8
|
# File 'lib/shifty/gang.rb', line 6
def tags
@tags
end
|
Class Method Details
.[](*workers) ⇒ Object
47
48
49
|
# File 'lib/shifty/gang.rb', line 47
def [](*workers)
new workers
end
|
Instance Method Details
#append(worker) ⇒ Object
42
43
44
|
# File 'lib/shifty/gang.rb', line 42
def append(worker)
roster << worker
end
|
#ready_to_work? ⇒ Boolean
24
25
26
|
# File 'lib/shifty/gang.rb', line 24
def ready_to_work?
roster.first.ready_to_work?
end
|
#shift ⇒ Object
16
17
18
19
20
21
22
|
# File 'lib/shifty/gang.rb', line 16
def shift
if criteria_passes?
roster.last.shift
else
roster.first.supply.shift
end
end
|
#supplies(subscribing_worker) ⇒ Object
Also known as:
|
36
37
38
39
|
# File 'lib/shifty/gang.rb', line 36
def supplies(subscribing_worker)
subscribing_worker.supply = self
subscribing_worker
end
|
#supply ⇒ Object
28
29
30
|
# File 'lib/shifty/gang.rb', line 28
def supply
roster.first.supply
end
|
#supply=(supplier) ⇒ Object
32
33
34
|
# File 'lib/shifty/gang.rb', line 32
def supply=(supplier)
roster.first.supply = supplier
end
|