Class: Benedictus::Plan::Tree

Inherits:
Object
  • Object
show all
Defined in:
lib/benedictus/plan/tree.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(root, planning_time: nil, execution_time: nil, triggers: [], raw: nil) ⇒ Tree

Returns a new instance of Tree.



8
9
10
11
12
13
14
# File 'lib/benedictus/plan/tree.rb', line 8

def initialize(root, planning_time: nil, execution_time: nil, triggers: [], raw: nil)
  @root           = root
  @planning_time  = planning_time
  @execution_time = execution_time
  @triggers       = triggers
  @raw            = raw
end

Instance Attribute Details

#execution_timeObject (readonly)

Returns the value of attribute execution_time.



6
7
8
# File 'lib/benedictus/plan/tree.rb', line 6

def execution_time
  @execution_time
end

#planning_timeObject (readonly)

Returns the value of attribute planning_time.



6
7
8
# File 'lib/benedictus/plan/tree.rb', line 6

def planning_time
  @planning_time
end

#rawObject (readonly)

Returns the value of attribute raw.



6
7
8
# File 'lib/benedictus/plan/tree.rb', line 6

def raw
  @raw
end

#rootObject (readonly)

Returns the value of attribute root.



6
7
8
# File 'lib/benedictus/plan/tree.rb', line 6

def root
  @root
end

#triggersObject (readonly)

Returns the value of attribute triggers.



6
7
8
# File 'lib/benedictus/plan/tree.rb', line 6

def triggers
  @triggers
end

Instance Method Details

#analyzed?Boolean

Returns:

  • (Boolean)


32
33
34
# File 'lib/benedictus/plan/tree.rb', line 32

def analyzed?
  root.analyzed?
end

#each_node(&block) ⇒ Object



16
17
18
19
20
# File 'lib/benedictus/plan/tree.rb', line 16

def each_node(&block)
  return enum_for(:each_node) unless block

  traverse(root, &block)
end

#total_costObject



22
23
24
# File 'lib/benedictus/plan/tree.rb', line 22

def total_cost
  root.total_cost
end

#total_rowsObject



36
37
38
# File 'lib/benedictus/plan/tree.rb', line 36

def total_rows
  root.actual_rows || root.plan_rows
end

#total_timeObject



26
27
28
29
30
# File 'lib/benedictus/plan/tree.rb', line 26

def total_time
  return execution_time if execution_time

  root.actual_total_time
end

#warningsObject



40
41
42
# File 'lib/benedictus/plan/tree.rb', line 40

def warnings
  each_node.flat_map(&:warnings)
end