Class: Cursor

Inherits:
Object
  • Object
show all
Defined in:
lib/quantile_estimator/cursor.rb

Instance Method Summary collapse

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

#nextObject



17
18
19
# File 'lib/quantile_estimator/cursor.rb', line 17

def next
  Cursor.new(@array, @start + 1)
end

#previousObject



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