module Doku::DancingLinks::VerticalLinks

This module is mixed into objects to give them their “up” and “down” links, and to give some convenient methods for changing those links. Every class this module is added to gains to attr_accessors: up and down.

Public Class Methods

included(klass) click to toggle source
# File lib/doku/dancing_links.rb, line 106
def self.included(klass)
  klass.instance_eval do
    attr_accessor :up, :down
  end
end

Public Instance Methods

insert_above(other) click to toggle source

Inserts this object above the specified object in the vertical list.

# File lib/doku/dancing_links.rb, line 130
def insert_above(other)
  self.up, self.down = other.up, other
  reinsert_vertical
end
reinsert_vertical() click to toggle source

Reinserts this object into the vertical linked list by making the former up and down neighors point to this object instead of each other. The former up and down neighbors are simply found by looking at the “up” and “down” links for this object, which still point to them. This undoes the effect of {#remove_vertical}.

# File lib/doku/dancing_links.rb, line 124
def reinsert_vertical
  up.down = down.up = self
end
remove_vertical() click to toggle source

Removes this object from the vertical linked list by making the up and down neighbors point at each other instead of this object. This can later be undone with {#reinsert_vertical}

# File lib/doku/dancing_links.rb, line 115
def remove_vertical
  down.up, up.down = up, down
end