Class: Cursor
- Inherits:
-
Object
- Object
- Cursor
- Defined in:
- lib/quantile_estimator/cursor.rb
Instance Method Summary collapse
-
#initialize(array, start = 0) ⇒ Cursor
constructor
A new instance of Cursor.
- #next ⇒ Object
- #previous ⇒ Object
- #remove! ⇒ Object
- #~ ⇒ Object
Constructor Details
#initialize(array, start = 0) ⇒ Cursor
Returns a new instance of Cursor.
2 3 4 5 |
# File 'lib/quantile_estimator/cursor.rb', line 2 def initialize(array, start=0) @array = array @start = start end |
Instance Method Details
#next ⇒ Object
17 18 19 |
# File 'lib/quantile_estimator/cursor.rb', line 17 def next Cursor.new(@array, @start + 1) end |
#previous ⇒ Object
21 22 23 |
# File 'lib/quantile_estimator/cursor.rb', line 21 def previous Cursor.new(@array, @start - 1) end |
#remove! ⇒ Object
13 14 15 |
# File 'lib/quantile_estimator/cursor.rb', line 13 def remove! @array.delete_at(@start) end |
#~ ⇒ Object
7 8 9 10 11 |
# File 'lib/quantile_estimator/cursor.rb', line 7 def ~ if @start >= 0 @array[@start] end end |