Class: Mutant::Parallel::Source::Array

Inherits:
Object
  • Object
show all
Defined in:
lib/mutant/parallel/source.rb

Overview

Job source backed by a finite array

Instance Method Summary collapse

Constructor Details

#initializeundefined

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Initialize objecto



38
39
40
41
42
# File 'lib/mutant/parallel/source.rb', line 38

def initialize(*)
  super

  @next_index = 0
end

Instance Method Details

#nextObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Return next job

Returns:

  • (Object)

Raises:



63
64
65
66
67
68
# File 'lib/mutant/parallel/source.rb', line 63

def next
  fail NoJobError unless next?
  jobs.fetch(@next_index).tap do
    @next_index += 1
  end
end

#next?Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Test if next job is available

Returns:

  • (Boolean)


50
51
52
# File 'lib/mutant/parallel/source.rb', line 50

def next?
  @next_index < jobs.length
end