Class: RubyPx::Dataset::Data
- Inherits:
-
Object
- Object
- RubyPx::Dataset::Data
- Defined in:
- lib/ruby_px/dataset/data.rb
Constant Summary collapse
- CHUNK_SIZE =
5_000
Instance Attribute Summary collapse
-
#current_chunk_index ⇒ Object
Returns the value of attribute current_chunk_index.
Instance Method Summary collapse
- #at(index) ⇒ Object
- #concat(array) ⇒ Object
- #indexes_count ⇒ Object
-
#initialize ⇒ Data
constructor
A new instance of Data.
Constructor Details
#initialize ⇒ Data
Returns a new instance of Data.
8 9 10 |
# File 'lib/ruby_px/dataset/data.rb', line 8 def initialize @current_chunk_index = 0 end |
Instance Attribute Details
#current_chunk_index ⇒ Object
Returns the value of attribute current_chunk_index.
6 7 8 |
# File 'lib/ruby_px/dataset/data.rb', line 6 def current_chunk_index @current_chunk_index end |
Instance Method Details
#at(index) ⇒ Object
12 13 14 15 16 17 |
# File 'lib/ruby_px/dataset/data.rb', line 12 def at index chunk_index = index/CHUNK_SIZE index_inside_chunk = index%CHUNK_SIZE get_chunk(chunk_index)[index_inside_chunk] end |
#concat(array) ⇒ Object
19 20 21 22 23 24 25 26 |
# File 'lib/ruby_px/dataset/data.rb', line 19 def concat array current_chunk.concat(array) if current_chunk.size > CHUNK_SIZE excess = current_chunk.pop(current_chunk.size-CHUNK_SIZE) self.current_chunk_index += 1 concat(excess) end end |
#indexes_count ⇒ Object
28 29 30 |
# File 'lib/ruby_px/dataset/data.rb', line 28 def indexes_count self.current_chunk_index+1 end |