Class: Cyrun::GroupBuilder
- Inherits:
-
Object
- Object
- Cyrun::GroupBuilder
- Defined in:
- lib/cyrun/group_builder.rb
Instance Method Summary collapse
- #add_task(task) ⇒ Object
- #any? ⇒ Boolean
-
#initialize(group_size) ⇒ GroupBuilder
constructor
A new instance of GroupBuilder.
- #next_group ⇒ Object
Constructor Details
#initialize(group_size) ⇒ GroupBuilder
Returns a new instance of GroupBuilder.
5 6 7 8 |
# File 'lib/cyrun/group_builder.rb', line 5 def initialize(group_size) @queue = [] @group_size = group_size end |
Instance Method Details
#add_task(task) ⇒ Object
11 12 13 |
# File 'lib/cyrun/group_builder.rb', line 11 def add_task(task) @queue.push task end |
#any? ⇒ Boolean
21 22 23 |
# File 'lib/cyrun/group_builder.rb', line 21 def any? @queue.any? end |
#next_group ⇒ Object
15 16 17 18 19 |
# File 'lib/cyrun/group_builder.rb', line 15 def next_group group = [] group.push @queue.shift while @queue.any? && group.size < @group_size group end |