Class: Qfill::Strategy::DrainToLimit
- Inherits:
-
Base
- Object
- Base
- Qfill::Strategy::DrainToLimit
show all
- Defined in:
- lib/qfill/strategy/drain_to_limit.rb
Constant Summary
collapse
- NAME =
:drain_to_limit
Instance Attribute Summary
Attributes inherited from Base
#added, #ratio_modifier, #tally
Instance Method Summary
collapse
Methods inherited from Base
#bump!, #default_pusher, #fill_to_ratio!, #initialize, #name, #remaining
Instance Method Details
#fill_according_to_list_ratios! ⇒ Object
33
34
35
36
37
38
39
40
41
42
43
|
# File 'lib/qfill/strategy/drain_to_limit.rb', line 33
def fill_according_to_list_ratios!
result.list_ratios.each do |list_name, list_ratio|
max_from_list = Qfill::Result.get_limit_from_max_and_ratio(result.max, list_ratio, remaining)
array_to_push = popper.next_objects!(list_name, max_from_list)
self.added = result.push(array_to_push, list_name)
popper.current_index = popper.index_of(list_name)
puts "[fill_according_to_list_ratios!]#{self}[#{list_name}][added:#{added}]" if Qfill::VERBOSE
bump!
break if is_full?
end
end
|
#fill_up_to_ratio! ⇒ Object
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
# File 'lib/qfill/strategy/drain_to_limit.rb', line 16
def fill_up_to_ratio!
num_primary = popper.primary.length
ratio = 1.0 / num_primary max_from_list = Qfill::Result.get_limit_from_max_and_ratio(result.max, ratio, remaining)
popper.primary.each_with_index do |queue, idx|
mod = result.max % num_primary
max_from_list += (mod / num_primary).ceil if idx.zero? && mod.positive?
array_to_push = popper.next_objects!(queue.name, [max_from_list, remaining].min)
self.added = result.push(array_to_push, queue.name)
popper.current_index = popper.index_of(queue.name)
puts "[fill_up_to_ratio!]#{self}[Q:#{queue.name}][added:#{added}]" if Qfill::VERBOSE
bump!
break if is_full?
end
end
|
#on_fill! ⇒ Object
8
9
10
|
# File 'lib/qfill/strategy/drain_to_limit.rb', line 8
def on_fill!
end
|