Module: Doku::DancingLinks::VerticalLinks

Includes:
Uninspectable
Included in:
LinkMatrix::Column, LinkMatrix::Node
Defined in:
lib/doku/dancing_links.rb

Overview

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.

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Uninspectable

#inspect

Class Method Details

.included(klass) ⇒ Object



106
107
108
109
110
# File 'lib/doku/dancing_links.rb', line 106

def self.included(klass)
  klass.instance_eval do
    attr_accessor :up, :down
  end
end

Instance Method Details

#insert_above(other) ⇒ Object

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



130
131
132
133
# File 'lib/doku/dancing_links.rb', line 130

def insert_above(other)
  self.up, self.down = other.up, other
  reinsert_vertical
end

#reinsert_verticalObject

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.



124
125
126
# File 'lib/doku/dancing_links.rb', line 124

def reinsert_vertical
  up.down = down.up = self
end

#remove_verticalObject

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



115
116
117
# File 'lib/doku/dancing_links.rb', line 115

def remove_vertical
  down.up, up.down = up, down
end