Class: Andromeda::Kit::FileChunker
- Inherits:
-
FileReader
- Object
- Impl::ConnectorBase
- Impl::ProtoPlan
- Plan
- FileReader
- Andromeda::Kit::FileChunker
- Defined in:
- lib/andromeda/kit.rb
Instance Attribute Summary collapse
-
#num_chunks ⇒ Object
readonly
Returns the value of attribute num_chunks.
Attributes inherited from FileReader
Attributes inherited from Plan
#error_level, #log, #marker, #nick, #trace_enter, #trace_exit
Attributes inherited from Impl::ProtoPlan
Instance Method Summary collapse
-
#initialize(config = {}) ⇒ FileChunker
constructor
A new instance of FileChunker.
- #on_enter(key, val) ⇒ Object
Methods inherited from FileReader
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
Methods inherited from Impl::ConnectorBase
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_chunks ⇒ Object (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 = [:first] lst = [:last] sz = [: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 |