Class: Cyrun::GroupBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/cyrun/group_builder.rb

Instance Method Summary collapse

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

Parameters:



11
12
13
# File 'lib/cyrun/group_builder.rb', line 11

def add_task(task)
  @queue.push task
end

#any?Boolean

Returns:

  • (Boolean)


21
22
23
# File 'lib/cyrun/group_builder.rb', line 21

def any?
  @queue.any?
end

#next_groupObject



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