Class: CFA::AugeasTreeValue

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

Constructor Details

#initialize(tree, value) ⇒ AugeasTreeValue

Returns a new instance of AugeasTreeValue.



105
106
107
108
109
# File 'lib/cfa/augeas_parser.rb', line 105

def initialize(tree, value)
  @tree = tree
  @value = value
  @modified = false
end

Instance Attribute Details

#treeAugeasTree

Returns the subtree below the node.

Returns:



103
104
105
# File 'lib/cfa/augeas_parser.rb', line 103

def tree
  @tree
end

#valueString

Returns the value in the node.

Returns:

  • (String)

    the value in the node



101
102
103
# File 'lib/cfa/augeas_parser.rb', line 101

def value
  @value
end

Instance Method Details

#==(other) ⇒ Object Also known as: eql?



121
122
123
124
125
# File 'lib/cfa/augeas_parser.rb', line 121

def ==(other)
  [:class, :value, :tree].all? do |a|
    public_send(a) == other.public_send(a)
  end
end

#[](key) ⇒ String, ...

Finds given key in tree.

Parameters:

  • key (String)

Returns:



112
113
114
# File 'lib/cfa/augeas_parser.rb', line 112

def [](key)
  tree[key]
end

#modified?Boolean

Returns true if the value has been modified.

Returns:

  • (Boolean)

    true if the value has been modified



128
129
130
# File 'lib/cfa/augeas_parser.rb', line 128

def modified?
  @modified
end