class Andromeda::Kit::Targeting::FileReader::FileChunker

Attributes

num_chunks[R]

Public Class Methods

new(config = {}) click to toggle source
# File lib/andromeda/kit.rb, line 169
def initialize(config = {})
  super config
  @num_chunks ||= Guides::PoolGuide.num_procs
end

Public Instance Methods

on_enter(key, val) click to toggle source
# File lib/andromeda/kit.rb, line 174
def on_enter(key, val)
  num_c = num_chunks
  super key, val do |f|
    fst = tags[:first]
    lst = tags[:last]
    sz  = tags[:num] / num_c rescue 1
    sz  = 1 if sz < 0
    while fst <= lst
      nxt = fst + sz
      nxt = lst if nxt > lst
      exit << Range.new(fst, nxt)
      fst = nxt + 1
    end
  end
end