Class: SportsSouth::Chunker
- Inherits:
-
Object
- Object
- SportsSouth::Chunker
- Defined in:
- lib/sports_south/chunker.rb
Instance Attribute Summary collapse
-
#chunk ⇒ Object
Returns the value of attribute chunk.
-
#current_count ⇒ Object
Returns the value of attribute current_count.
-
#size ⇒ Object
Returns the value of attribute size.
-
#total_count ⇒ Object
Returns the value of attribute total_count.
Instance Method Summary collapse
- #add(row) ⇒ Object
-
#initialize(size, total_count = nil) ⇒ Chunker
constructor
A new instance of Chunker.
- #is_complete? ⇒ Boolean
- #is_full? ⇒ Boolean
- #reset! ⇒ Object
Constructor Details
#initialize(size, total_count = nil) ⇒ Chunker
Returns a new instance of Chunker.
6 7 8 9 10 11 |
# File 'lib/sports_south/chunker.rb', line 6 def initialize(size, total_count = nil) @size = size @chunk = Array.new @current_count = 0 @total_count = total_count end |
Instance Attribute Details
#chunk ⇒ Object
Returns the value of attribute chunk.
4 5 6 |
# File 'lib/sports_south/chunker.rb', line 4 def chunk @chunk end |
#current_count ⇒ Object
Returns the value of attribute current_count.
4 5 6 |
# File 'lib/sports_south/chunker.rb', line 4 def current_count @current_count end |
#size ⇒ Object
Returns the value of attribute size.
4 5 6 |
# File 'lib/sports_south/chunker.rb', line 4 def size @size end |
#total_count ⇒ Object
Returns the value of attribute total_count.
4 5 6 |
# File 'lib/sports_south/chunker.rb', line 4 def total_count @total_count end |
Instance Method Details
#add(row) ⇒ Object
13 14 15 16 17 18 19 |
# File 'lib/sports_south/chunker.rb', line 13 def add(row) self.reset! if is_full? @chunk.push(row) @current_count += 1 end |
#is_complete? ⇒ Boolean
29 30 31 |
# File 'lib/sports_south/chunker.rb', line 29 def is_complete? @total_count == @current_count end |
#is_full? ⇒ Boolean
25 26 27 |
# File 'lib/sports_south/chunker.rb', line 25 def is_full? @chunk.count == @size end |
#reset! ⇒ Object
21 22 23 |
# File 'lib/sports_south/chunker.rb', line 21 def reset! @chunk.clear end |