MindoroMarine::Acts::HausdorffSpace::ClassMethods

Public Instance Methods

bias() click to toggle source

Return the bias supplied in the options to to acts_as_hausdorff_space or the default 1E6

# File lib/acts_as_hausdorff_space.rb, line 126
    def bias
      acts_as_hausdorff_space_options[:bias]
    end
full_tree() click to toggle source

use the instance method build_full_tree on the root to get all the children set up in a tree

# File lib/acts_as_hausdorff_space.rb, line 106
    def full_tree
      root.build_full_tree
    end
left_col_name() click to toggle source

Return the left column name. Either the one supplied in the options to acts_as_hausdorff_space or the default “lft“

# File lib/acts_as_hausdorff_space.rb, line 111
    def left_col_name
        acts_as_hausdorff_space_options[:left_column]
    end
max_double() click to toggle source

Return the max_double supplied in the options to to acts_as_hausdorff_space or the default 1E20

# File lib/acts_as_hausdorff_space.rb, line 121
    def max_double
      acts_as_hausdorff_space_options[:max_double]
    end
right_col_name() click to toggle source

Return the right column name. Either the one supplied in the options to acts_as_hausdorff_space or the default “rgt“

# File lib/acts_as_hausdorff_space.rb, line 116
    def right_col_name
        acts_as_hausdorff_space_options[:right_column]
    end
root() click to toggle source

get the first root from roots

# File lib/acts_as_hausdorff_space.rb, line 102
    def root
        roots.first
    end
roots() click to toggle source

Get all the top level roots. This does a find of all records with no immediate parent in the database. When they’re loaded they get a virtual root attached as their parent. This is to make sure that every node has a parent which helps to generalise and simplify the code for working out left and right boundaries.

# File lib/acts_as_hausdorff_space.rb, line 85
    def roots
     top_levels =    self.find( :all, :conditions => "not exists (select t1.id from #{self.table_name} t1
                                                                       where t1.#{left_col_name} <#{self.table_name}.#{left_col_name} 
                                                                       and t1.#{right_col_name} > #{self.table_name}.#{right_col_name})",:order=>"#{left_col_name}")
     self.virtual_root.children.clear
     top_levels.each do |tl|
     begin
     tl.in_tree = true
     self.virtual_root.children << tl
     tl.in_tree = false
     rescue
     tl.in_tree = false
     raise
     end
     end 
    end
virtual_root() click to toggle source

Return the virtual root. This is an in memory only parent to all the roots, the left is set to -max_double and the right to max_double

# File lib/acts_as_hausdorff_space.rb, line 130
    def virtual_root 
     acts_as_hausdorff_space_options[:virtual_root]
    end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.