Class: Puppet::Pops::Lookup::ExplainNode Private

Inherits:
Object
  • Object
show all
Defined in:
lib/puppet/pops/lookup/explainer.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

The ExplainNode contains information of a specific node in a tree traversed during lookup. The tree can be traversed using the ‘parent` and `branches` attributes of each node.

Each leaf node contains information about what happened when the leaf of the branch was traversed.

Direct Known Subclasses

ExplainMergeSource, ExplainTreeNode, Explainer

Instance Method Summary collapse

Instance Method Details

#branchesObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



12
13
14
# File 'lib/puppet/pops/lookup/explainer.rb', line 12

def branches
  @branches ||= []
end

#dump_on(io, indent, first_indent) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



43
44
45
# File 'lib/puppet/pops/lookup/explainer.rb', line 43

def dump_on(io, indent, first_indent)
  dump_texts(io, indent)
end

#dump_texts(io, indent) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



47
48
49
# File 'lib/puppet/pops/lookup/explainer.rb', line 47

def dump_texts(io, indent)
  @texts.each { |text| io << indent << text << "\n" } if instance_variable_defined?(:@texts)
end

#explainObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



22
23
24
25
26
# File 'lib/puppet/pops/lookup/explainer.rb', line 22

def explain
  io = ''.dup
  dump_on(io, '', '')
  io
end

#inspectObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



28
29
30
# File 'lib/puppet/pops/lookup/explainer.rb', line 28

def inspect
  to_s
end

#text(text) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



38
39
40
41
# File 'lib/puppet/pops/lookup/explainer.rb', line 38

def text(text)
  @texts ||= []
  @texts << text
end

#to_hashObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



16
17
18
19
20
# File 'lib/puppet/pops/lookup/explainer.rb', line 16

def to_hash
  hash = {}
  hash[:branches] = @branches.map(&:to_hash) unless @branches.nil? || @branches.empty?
  hash
end

#to_sObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



32
33
34
35
36
# File 'lib/puppet/pops/lookup/explainer.rb', line 32

def to_s
  s = self.class.name
  s = "#{s} with #{@branches.size} branches" unless @branches.nil?
  s
end