class Iter::Elem

Attributes

val[RW]
visited[RW]

Public Class Methods

new(iter, val) click to toggle source
# File lib/epitools/iter.rb, line 74
def initialize(iter, val)
  @iter = iter
  @val  = val.is_a?(Elem) ? val.value : val
  @visited = false
end

Public Instance Methods

<=>(other) click to toggle source
# File lib/epitools/iter.rb, line 164
def <=>(other)
  case other
  when Elem
    @val <=> other.value
  else
    @val <=> other
  end
end
container() click to toggle source
# File lib/epitools/iter.rb, line 84
def container
  @iter.container
end
current() click to toggle source
# File lib/epitools/iter.rb, line 88
def current
  self
end
delete()
Alias for: remove
elem?() click to toggle source
# File lib/epitools/iter.rb, line 80
def elem?
  true
end
inspect() click to toggle source
# File lib/epitools/iter.rb, line 157
def inspect
  "<Elem: #{@val.inspect}>"
end
method_missing(name, *args) click to toggle source
# File lib/epitools/iter.rb, line 153
def method_missing(name, *args)
  @val.send(name, *args)
end
move_after(other) click to toggle source
# File lib/epitools/iter.rb, line 132
def move_after(other)
  remove
  container.insert(other.pos+1, self) # insert after pos
end
move_before(other) click to toggle source
# File lib/epitools/iter.rb, line 127
def move_before(other)
  remove
  container.insert(other.pos, self) # insert at pos and shift everything over
end
move_end()
Alias for: move_last
move_first() click to toggle source
# File lib/epitools/iter.rb, line 137
def move_first
  remove
  container.insert(0, self) # insert at beginning
end
Also aliased as: move_start
move_last() click to toggle source
# File lib/epitools/iter.rb, line 143
def move_last
  remove
  container.insert(-1, self) # insert at end
end
Also aliased as: move_end
move_start()
Alias for: move_first
next() click to toggle source
# File lib/epitools/iter.rb, line 96
def next
  p = pos+1
  if p >= container.size
    nil
  else
    container[p]
  end
end
pos() click to toggle source
# File lib/epitools/iter.rb, line 123
def pos
  container.index(self)
end
prev() click to toggle source
# File lib/epitools/iter.rb, line 105
def prev
  p = pos-1
  if p < 0
    nil
  else
    container[p]
  end
end
remove() click to toggle source
# File lib/epitools/iter.rb, line 114
def remove
  container.delete_at(pos)
end
Also aliased as: delete
replace_with(replacement) click to toggle source
# File lib/epitools/iter.rb, line 119
def replace_with(replacement)
  container[pos] = Elem.new(@iter, replacement)
end
value() click to toggle source
# File lib/epitools/iter.rb, line 149
def value
  @val
end
visited?() click to toggle source
# File lib/epitools/iter.rb, line 92
def visited?
  @visited
end