Module: TreeMethods

Included in:
Object
Defined in:
lib/tree_methods.rb,
lib/tree_methods/version.rb

Defined Under Namespace

Classes: Error

Constant Summary collapse

VERSION =
"0.2.0"

Instance Method Summary collapse

Instance Method Details

#follow(include_self = false, &block) ⇒ Object



8
9
10
11
12
# File 'lib/tree_methods.rb', line 8

def follow(include_self = false, &block) 
  result = include_self ? [self] : []
  follow_implementation(result, &block)
  result
end

#postorder(include_self = true, &block) ⇒ Object



20
21
22
23
24
# File 'lib/tree_methods.rb', line 20

def postorder(include_self = true, &block)
  result = []
  postorder_implementation(result, &block)
  include_self ? result + [self] : result
end

#preorder(include_self = true, &block) ⇒ Object



14
15
16
17
18
# File 'lib/tree_methods.rb', line 14

def preorder(include_self = true, &block)
  result = include_self ? [self] : []
  preorder_implementation(result, &block)
  result
end