Class: Cursor

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

Instance Method Summary (collapse)

Constructor Details

- (Cursor) initialize(array, start = 0)

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

- (Object) next



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

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

- (Object) previous



21
22
23
# File 'lib/quantile_estimator/cursor.rb', line 21

def previous
  Cursor.new(@array, @start - 1)
end

- (Object) remove!



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