Module: Tree

Defined in:
lib/modular_tree/implementations.rb,
lib/modular_tree.rb,
lib/modular_tree.rb,
lib/modular_tree/pool.rb,
lib/modular_tree/pairs.rb,
lib/modular_tree/filter.rb,
lib/modular_tree/matcher.rb,
lib/modular_tree/version.rb,
lib/modular_tree/separator.rb,
lib/modular_tree/algorithms.rb,
lib/modular_tree/properties.rb

Overview

TODO TODO TODO IDEA

External trees

node/branch/branches
  returns tree

this/parent/children
  returns data field

Internal trees

Unifies node and this

Both of internal and external trees have branch/branches relations.

Internal trees adds a parent/children relation

Only internal trees have parent/child relations. External trees have only branch/branches relations

Defined Under Namespace

Modules: BranchesProperty, ChildrenImplementation, ChildrenProperty, DotAlgorithms, DownTreeAlgorithms, DownTreeFilteredAlgorithms, ExternalChildrenArrayImplementation, ExternalParentImplementation, Implementation, InternalChildrenArrayImplementation, InternalChildrenHashImplementation, InternalChildrenImplementation, InternalChildrenListImplementation, InternalImplementation, InternalParentChildArrayImplementation, InternalParentChildImplementation, InternalParentImplementation, InternalRootImplementation, KeyProperty, KeysProperty, MatchExpression, NodeProperty, ParentChildProperty, ParentImplementation, ParentProperty, PathAlgorithms, Pool, Property, RootProperty, Separator, StemProperty, UpTreeAlgorithms Classes: AbstractMatcher, AbstractTree, ArrayTree, Filter, FilteredArrayTree, Matcher, NestedArrayTree, Pairs, TreeError

Constant Summary collapse

DEFAULT_SEPARATOR =
"."
VERSION =
"0.14.1"

Class Method Summary collapse

Class Method Details

.aggregate(arg, *args, &block) ⇒ Object

Module level algorithms on nested array trees



76
77
78
79
80
81
82
# File 'lib/modular_tree.rb', line 76

def self.aggregate(arg, *args, &block)
  case arg
    when Array; NestedArrayTree.new(arg).aggregate(*args, &block)
  else
    raise ArgumentError
  end
end

.class_of(arg) ⇒ Object

TODO: Hide



87
88
89
90
91
92
93
94
# File 'lib/modular_tree.rb', line 87

def self.class_of(arg)
  constrain arg, Array
  if arg.size == 2 && arg.last.is_a?(Array)
    NestedArrayTree
  else
    raise "Oops"
  end
end

.separatorObject



34
# File 'lib/modular_tree.rb', line 34

def Tree.separator = @separator ||= DEFAULT_SEPARATOR

.separator=(s) ⇒ Object



35
# File 'lib/modular_tree.rb', line 35

def Tree.separator=(s) @separator = s end