Class: Andromeda::Kit::FileChunker

Inherits:
FileReader show all
Defined in:
lib/andromeda/kit.rb

Instance Attribute Summary collapse

Attributes inherited from FileReader

#mode, #path

Attributes inherited from Plan

#error_level, #log, #marker, #nick, #trace_enter, #trace_exit

Attributes inherited from Impl::ProtoPlan

#guide, #id

Instance Method Summary collapse

Methods inherited from FileReader

#data_tag, #init_mode

Methods inherited from Plan

#initialize_copy, #pool, #tap, #to_short_s

Methods inherited from Impl::ProtoPlan

#>>, attr_spot, #attr_spot_name?, #attr_spot_names, attr_spot_names, #current_name, #current_scope, #data_key, #data_map, #data_tag, #data_val, #dest, #entry, #init_guide, #initialize_copy, #key_label, #key_spot, meth_spot, #meth_spot_name?, #meth_spot_names, meth_spot_names, #mute, name_spot, #post_data, #post_to, #public_spot, #selects?, #signal_name?, #signal_names, signal_names, signal_spot, #spot_name?, spot_names, #spot_names, #tags, #to_short_s, #via

Methods included from Impl::To_S

short_s, #to_s, #to_short_s

Methods inherited from Impl::ConnectorBase

#post, #post_local, #start

Constructor Details

#initialize(config = {}) ⇒ FileChunker

Returns a new instance of FileChunker.



149
150
151
152
# File 'lib/andromeda/kit.rb', line 149

def initialize(config = {})
	super config
	@num_chunks ||= Guides::PoolGuide.num_procs
end

Instance Attribute Details

#num_chunksObject (readonly)

Returns the value of attribute num_chunks.



147
148
149
# File 'lib/andromeda/kit.rb', line 147

def num_chunks
  @num_chunks
end

Instance Method Details

#on_enter(key, val) ⇒ Object



154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
# File 'lib/andromeda/kit.rb', line 154

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