Class: Puppet::Pops::Lookup::ExplainTreeNode Private
- Inherits:
-
ExplainNode
- Object
- ExplainNode
- Puppet::Pops::Lookup::ExplainTreeNode
- Defined in:
- lib/puppet/pops/lookup/explainer.rb
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.
Direct Known Subclasses
ExplainDataProvider, ExplainGlobal, ExplainInterpolate, ExplainInvalidKey, ExplainKeySegment, ExplainLocation, ExplainMerge, ExplainModule, ExplainScope, ExplainSubLookup, ExplainTop
Instance Attribute Summary collapse
- #event ⇒ Object readonly private
- #key ⇒ Object private
- #parent ⇒ Object readonly private
- #value ⇒ Object readonly private
Instance Method Summary collapse
- #dump_outcome(io, indent) ⇒ Object private
- #dump_value(io, indent, value) ⇒ Object private
- #found(key, value) ⇒ Object private
- #found_in_defaults(key, value) ⇒ Object private
- #found_in_overrides(key, value) ⇒ Object private
- #increase_indent(indent) ⇒ Object private
-
#initialize(parent) ⇒ ExplainTreeNode
constructor
private
A new instance of ExplainTreeNode.
- #location_not_found ⇒ Object private
- #not_found(key) ⇒ Object private
- #result(value) ⇒ Object private
- #to_hash ⇒ Object private
- #to_s ⇒ Object private
- #type ⇒ Object private
Methods inherited from ExplainNode
#branches, #dump_on, #dump_texts, #explain, #inspect, #text
Constructor Details
#initialize(parent) ⇒ ExplainTreeNode
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.
Returns a new instance of ExplainTreeNode.
55 56 57 58 |
# File 'lib/puppet/pops/lookup/explainer.rb', line 55 def initialize(parent) @parent = parent @event = nil end |
Instance Attribute Details
#event ⇒ Object (readonly)
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.
52 53 54 |
# File 'lib/puppet/pops/lookup/explainer.rb', line 52 def event @event end |
#key ⇒ 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.
53 54 55 |
# File 'lib/puppet/pops/lookup/explainer.rb', line 53 def key @key end |
#parent ⇒ Object (readonly)
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.
52 53 54 |
# File 'lib/puppet/pops/lookup/explainer.rb', line 52 def parent @parent end |
#value ⇒ Object (readonly)
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.
52 53 54 |
# File 'lib/puppet/pops/lookup/explainer.rb', line 52 def value @value end |
Instance Method Details
#dump_outcome(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.
110 111 112 113 114 115 116 117 118 119 120 121 122 |
# File 'lib/puppet/pops/lookup/explainer.rb', line 110 def dump_outcome(io, indent) case @event when :not_found io << indent << 'No such key: "' << @key << "\"\n" when :found, :found_in_overrides, :found_in_defaults io << indent << 'Found key: "' << @key << '" value: ' dump_value(io, indent, @value) io << ' in overrides' if @event == :found_in_overrides io << ' in defaults' if @event == :found_in_defaults io << "\n" end dump_texts(io, indent) end |
#dump_value(io, indent, value) ⇒ 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.
124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 |
# File 'lib/puppet/pops/lookup/explainer.rb', line 124 def dump_value(io, indent, value) case value when Hash io << '{' unless value.empty? inner_indent = increase_indent(indent) value.reduce("\n") do |sep, (k, v)| io << sep << inner_indent dump_value(io, inner_indent, k) io << ' => ' dump_value(io, inner_indent, v) ",\n" end io << "\n" << indent end io << '}' when Array io << '[' unless value.empty? inner_indent = increase_indent(indent) value.reduce("\n") do |sep, v| io << sep << inner_indent dump_value(io, inner_indent, v) ",\n" end io << "\n" << indent end io << ']' else io << value.inspect end end |
#found(key, value) ⇒ 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.
72 73 74 75 76 |
# File 'lib/puppet/pops/lookup/explainer.rb', line 72 def found(key, value) @key = key.to_s @value = value @event = :found end |
#found_in_defaults(key, value) ⇒ 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.
66 67 68 69 70 |
# File 'lib/puppet/pops/lookup/explainer.rb', line 66 def found_in_defaults(key, value) @key = key.to_s @value = value @event = :found_in_defaults end |
#found_in_overrides(key, value) ⇒ 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.
60 61 62 63 64 |
# File 'lib/puppet/pops/lookup/explainer.rb', line 60 def found_in_overrides(key, value) @key = key.to_s @value = value @event = :found_in_overrides end |
#increase_indent(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.
92 93 94 |
# File 'lib/puppet/pops/lookup/explainer.rb', line 92 def increase_indent(indent) indent + ' ' end |
#location_not_found ⇒ 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.
88 89 90 |
# File 'lib/puppet/pops/lookup/explainer.rb', line 88 def location_not_found @event = :location_not_found end |
#not_found(key) ⇒ 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.
83 84 85 86 |
# File 'lib/puppet/pops/lookup/explainer.rb', line 83 def not_found(key) @key = key.to_s @event = :not_found end |
#result(value) ⇒ 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.
78 79 80 81 |
# File 'lib/puppet/pops/lookup/explainer.rb', line 78 def result(value) @value = value @event = :result end |
#to_hash ⇒ 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.
96 97 98 99 100 101 102 103 104 |
# File 'lib/puppet/pops/lookup/explainer.rb', line 96 def to_hash hash = super hash[:key] = @key unless @key.nil? hash[:value] = @value if [:found, :found_in_defaults, :found_in_overrides, :result].include?(@event) hash[:event] = @event unless @event.nil? hash[:texts] = @texts unless @texts.nil? hash[:type] = type hash end |
#to_s ⇒ 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.
157 158 159 |
# File 'lib/puppet/pops/lookup/explainer.rb', line 157 def to_s "#{self.class.name}: #{@key}, #{@event}" end |
#type ⇒ 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.
106 107 108 |
# File 'lib/puppet/pops/lookup/explainer.rb', line 106 def type :root end |