Class: Array

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

Overview

:nodoc:

Instance Method Summary collapse

Instance Method Details

#parallel_subsets(n) ⇒ Object



111
112
113
114
115
116
117
118
119
120
# File 'lib/vendor/parallel/parallel.rb', line 111

def parallel_subsets( n )
  if n > 1
    slice_size = (size.to_f / n.to_f).ceil
    (0...(size.to_f / slice_size)).map do |i|
      self[i*slice_size, slice_size.ceil]
    end
  else
    [ self ]
  end
end