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
#>>, #current_name, #current_scope, #data_key, #data_tag, #data_val, #dest, #entry, #init_guide, #initialize_copy, #key_label, #key_spot, #map_data, #mute, name_spot, #post_data, #post_to, #public_spot, #selects?, #signal_name?, signal_names, #signal_names, signal_spot, spot_attr, #spot_attr_name?, spot_attr_names, #spot_attr_names, spot_meth, #spot_meth_name?, #spot_meth_names, spot_meth_names, #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.
169 170 171 172 |
# File 'lib/andromeda/kit.rb', line 169 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.
167 168 169 |
# File 'lib/andromeda/kit.rb', line 167 def num_chunks @num_chunks end |
Instance Method Details
#on_enter(key, val) ⇒ Object
174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 |
# File 'lib/andromeda/kit.rb', line 174 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 |