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.
62 63 64 65 66 67 |
# File 'lib/cfa/augeas_parser/writer.rb', line 62 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.
59 60 61 |
# File 'lib/cfa/augeas_parser/writer.rb', line 59 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.
58 59 60 |
# File 'lib/cfa/augeas_parser/writer.rb', line 58 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.
60 61 62 |
# File 'lib/cfa/augeas_parser/writer.rb', line 60 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
103 104 105 |
# File 'lib/cfa/augeas_parser/writer.rb', line 103 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.
109 110 111 112 113 114 115 116 |
# File 'lib/cfa/augeas_parser/writer.rb', line 109 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.
120 121 122 123 124 125 126 127 |
# File 'lib/cfa/augeas_parser/writer.rb', line 120 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.
80 81 82 83 84 85 86 |
# File 'lib/cfa/augeas_parser/writer.rb', line 80 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.
69 70 71 |
# File 'lib/cfa/augeas_parser/writer.rb', line 69 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.
73 74 75 76 77 78 |
# File 'lib/cfa/augeas_parser/writer.rb', line 73 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.
91 92 93 94 95 96 97 98 99 |
# File 'lib/cfa/augeas_parser/writer.rb', line 91 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 |