Class: Docket::RobinList

Inherits:
Object
  • Object
show all
Defined in:
lib/docket/robin_list.rb

Instance Method Summary collapse

Constructor Details

#initialize(array) ⇒ RobinList

Returns a new instance of RobinList.



5
6
7
# File 'lib/docket/robin_list.rb', line 5

def initialize(array)
  @array = array
end

Instance Method Details

#fetch_after(e) ⇒ Object



25
26
27
# File 'lib/docket/robin_list.rb', line 25

def fetch_after(e)
  fetch_next(@array.index(e))
end

#fetch_before(e) ⇒ Object



29
30
31
# File 'lib/docket/robin_list.rb', line 29

def fetch_before(e)
  fetch_previous(@array.index(e))
end

#fetch_next(index = 0) ⇒ Object



21
22
23
# File 'lib/docket/robin_list.rb', line 21

def fetch_next(index=0)
  index.nil? ? nil : @array.push(@array.shift)[index]
end

#fetch_previous(index = 0) ⇒ Object



17
18
19
# File 'lib/docket/robin_list.rb', line 17

def fetch_previous(index=0)
  index.nil? ? nil : @array.unshift(@array.pop)[index]
end

#listObject



13
14
15
# File 'lib/docket/robin_list.rb', line 13

def list
  @array
end

#sizeObject



9
10
11
# File 'lib/docket/robin_list.rb', line 9

def size
  @array.size
end