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

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

Overview

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

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



35
36
37
38
39
# File 'lib/mutant/parallel/source.rb', line 35

def initialize(*)
  super

  @next_index = 0
end

Instance Method Details

#nextJob

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.

Next job

Returns:

Raises:



54
55
56
57
58
59
# File 'lib/mutant/parallel/source.rb', line 54

def next
  fail NoJobError unless next?
  Job.new(index: @next_index, payload: 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)


44
45
46
# File 'lib/mutant/parallel/source.rb', line 44

def next?
  @next_index < jobs.length
end