Class: CFA::AugeasWriter::LocatedEntry Private
- Inherits:
-
Object
- Object
- CFA::AugeasWriter::LocatedEntry
- Defined in:
- lib/cfa/augeas_parser/writer.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.
CFA::AugeasElement together with information about its location and a few helper methods to detect siblings.
Instance Attribute Summary collapse
- #entry ⇒ Object readonly private
- #prefix ⇒ Object readonly private
- #tree ⇒ Object readonly private
Instance Method Summary collapse
-
#any_following? ⇒ true, false
private
Returns true if there is any following entry in the Augeas tree.
-
#entry_tree ⇒ AugeasTree
private
The Augeas tree nested under this entry.
-
#entry_value ⇒ String?
private
If the value is an CFA::AugeasTree then return nil.
-
#initialize(tree, entry, prefix) ⇒ LocatedEntry
constructor
private
A new instance of LocatedEntry.
- #key ⇒ Object private
- #orig_key ⇒ Object private
- #path ⇒ Object private
-
#preceding_existing ⇒ LocatedEntry?
private
A preceding entry that already exists in the Augeas tree or nil if it does not exist.
Constructor Details
#initialize(tree, entry, prefix) ⇒ LocatedEntry
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 LocatedEntry.
60 61 62 63 64 65 |
# File 'lib/cfa/augeas_parser/writer.rb', line 60 def initialize(tree, entry, prefix) @tree = tree @entry = entry @prefix = prefix detect_tree_value_modification end |
Instance Attribute Details
#entry ⇒ 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.
57 58 59 |
# File 'lib/cfa/augeas_parser/writer.rb', line 57 def entry @entry end |
#prefix ⇒ 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.
56 57 58 |
# File 'lib/cfa/augeas_parser/writer.rb', line 56 def prefix @prefix end |
#tree ⇒ 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.
58 59 60 |
# File 'lib/cfa/augeas_parser/writer.rb', line 58 def tree @tree end |
Instance Method Details
#any_following? ⇒ true, false
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 true if there is any following entry in the Augeas tree
101 102 103 |
# File 'lib/cfa/augeas_parser/writer.rb', line 101 def any_following? following_entries.any? { |e| e[:operation] != :remove } end |
#entry_tree ⇒ AugeasTree
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 the Augeas tree nested under this entry. If there is no such tree, it creates an empty one.
107 108 109 110 111 112 113 114 |
# File 'lib/cfa/augeas_parser/writer.rb', line 107 def entry_tree value = entry[:value] case value when AugeasTree then value when AugeasTreeValue then value.tree else AugeasTree.new end end |
#entry_value ⇒ String?
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.
If the value is an CFA::AugeasTree then return nil.
118 119 120 121 122 123 124 125 |
# File 'lib/cfa/augeas_parser/writer.rb', line 118 def entry_value value = entry[:value] case value when AugeasTree then nil when AugeasTreeValue then value.value else value end 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.
78 79 80 81 82 83 84 |
# File 'lib/cfa/augeas_parser/writer.rb', line 78 def key return @key if @key @key = @entry[:key] @key = @key[0..-3] if @key.end_with?("[]") @key end |
#orig_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.
67 68 69 |
# File 'lib/cfa/augeas_parser/writer.rb', line 67 def orig_key entry[:orig_key] end |
#path ⇒ 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.
71 72 73 74 75 76 |
# File 'lib/cfa/augeas_parser/writer.rb', line 71 def path return @path if @path return nil unless orig_key @path = @prefix + "/" + orig_key end |
#preceding_existing ⇒ LocatedEntry?
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 preceding entry that already exists in the Augeas tree or nil if it does not exist.
89 90 91 92 93 94 95 96 97 |
# File 'lib/cfa/augeas_parser/writer.rb', line 89 def preceding_existing preceding_entry = preceding_entries.reverse_each.find do |entry| entry[:operation] != :add end return nil unless preceding_entry LocatedEntry.new(tree, preceding_entry, prefix) end |