class Array

Public Instance Methods

rotate_until(&block) click to toggle source
# File lib/ext/array.rb, line 3
def rotate_until &block
  return if block[]
  found = false
  length.times do
    push shift
    if block[]
      found = true
      break
    end
  end
  raise IndexError unless found
end
rotate_until_first_equals(obj) click to toggle source
# File lib/ext/array.rb, line 16
def rotate_until_first_equals obj
  rotate_until { at(0) == obj }
end
slice_exists?(slice) click to toggle source
# File lib/ext/array.rb, line 20
def slice_exists? slice
  start = slice.first
  len = slice.size
  each_with_index do |e, i|
    return true if e == start && self[i,len] == slice
  end
  false
end
to_c() click to toggle source
# File lib/ext/array.rb, line 29
def to_c
  Terraformer::Coordinate.from_array self
end