Class: CFA::AugeasTreeValue
- Inherits:
-
Object
- Object
- CFA::AugeasTreeValue
- Defined in:
- lib/cfa/augeas_parser.rb
Overview
Represents a node that contains both a value and a subtree below it. For easier traversal it forwards ‘#[]` to the subtree.
Instance Attribute Summary collapse
-
#tree ⇒ AugeasTree
The subtree below the node.
-
#value ⇒ String
The value in the node.
Instance Method Summary collapse
- #==(other) ⇒ Object (also: #eql?)
-
#[](key) ⇒ String, ...
Finds given key in tree.
-
#initialize(tree, value) ⇒ AugeasTreeValue
constructor
A new instance of AugeasTreeValue.
-
#modified? ⇒ Boolean
True if the value has been modified.
Constructor Details
#initialize(tree, value) ⇒ AugeasTreeValue
Returns a new instance of AugeasTreeValue.
106 107 108 109 110 |
# File 'lib/cfa/augeas_parser.rb', line 106 def initialize(tree, value) @tree = tree @value = value @modified = false end |
Instance Attribute Details
#tree ⇒ AugeasTree
Returns the subtree below the node.
104 105 106 |
# File 'lib/cfa/augeas_parser.rb', line 104 def tree @tree end |
#value ⇒ String
Returns the value in the node.
102 103 104 |
# File 'lib/cfa/augeas_parser.rb', line 102 def value @value end |
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
122 123 124 125 126 |
# File 'lib/cfa/augeas_parser.rb', line 122 def ==(other) [:class, :value, :tree].all? do |a| public_send(a) == other.public_send(a) end end |
#[](key) ⇒ String, ...
Finds given key in tree.
113 114 115 |
# File 'lib/cfa/augeas_parser.rb', line 113 def [](key) tree[key] end |
#modified? ⇒ Boolean
Returns true if the value has been modified.
129 130 131 |
# File 'lib/cfa/augeas_parser.rb', line 129 def modified? @modified end |