Module: Iterable

Included in:
Array
Defined in:
lib/cartesian_iterator.rb

Instance Method Summary collapse

Instance Method Details

#nextObject



93
94
95
96
# File 'lib/cartesian_iterator.rb', line 93

def next
  @next_index or restart
  raw_next
end

#raw_nextObject



98
99
100
# File 'lib/cartesian_iterator.rb', line 98

def raw_next
  self[@next_index += 1]
end

#restartObject Also known as: start



87
88
89
90
# File 'lib/cartesian_iterator.rb', line 87

def restart
  @next_index = -1
  true
end

#restart_and_raw_nextObject



102
103
104
# File 'lib/cartesian_iterator.rb', line 102

def restart_and_raw_next
  self[@next_index = 0]
end