Class: CircularList

Inherits:
Array
  • Object
show all
Defined in:
lib/muse/circularlist.rb

Instance Method Summary collapse

Instance Method Details

#currentObject



7
8
9
10
# File 'lib/muse/circularlist.rb', line 7

def current
  @index ||= 0
  get_at(@index)
end

#indexObject



2
3
4
5
# File 'lib/muse/circularlist.rb', line 2

def index
  @index ||=0
  @index.abs 
end

#next(num = 1) ⇒ Object



12
13
14
15
16
# File 'lib/muse/circularlist.rb', line 12

def next(num=1)
  @index ||= 0
  @index += num
  get_at(@index)
end

#previous(num = 1) ⇒ Object



18
19
20
21
22
# File 'lib/muse/circularlist.rb', line 18

def previous(num=1)
  @index ||= 0
  @index -= num
  get_at(@index)
end