Class: Installation::AutoinstProfile::ElementPath
- Inherits:
-
Object
- Object
- Installation::AutoinstProfile::ElementPath
- Extended by:
- Forwardable
- Defined in:
- library/general/src/lib/installation/autoinst_profile/element_path.rb
Overview
This class represents an element path in a profile
Class Method Summary collapse
-
.from_string(str) ⇒ ElementPath
Returns an ElementPath object from a string.
Instance Method Summary collapse
-
#==(other) ⇒ Boolean
Compares two paths.
-
#initialize(*parts) ⇒ ElementPath
constructor
Constructor.
-
#join(*parts_or_path) ⇒ ElementPath
Returns a new path composed by the given parts.
-
#to_a ⇒ Array<Integer,String>
Returns the path parts.
-
#to_s ⇒ String
Returns a generic path (old AutoYaST path used in ask-lists).
Constructor Details
#initialize(*parts) ⇒ ElementPath
Constructor
55 56 57 |
# File 'library/general/src/lib/installation/autoinst_profile/element_path.rb', line 55 def initialize(*parts) @parts = parts end |
Class Method Details
.from_string(str) ⇒ ElementPath
Returns an ElementPath object from a string
43 44 45 46 47 48 49 |
# File 'library/general/src/lib/installation/autoinst_profile/element_path.rb', line 43 def from_string(str) parts = str.split(",").each_with_object([]) do |part, all| element = (part =~ /\A\d+\Z/) ? part.to_i : part all.push(element) end new(*parts) end |
Instance Method Details
#==(other) ⇒ Boolean
Compares two paths
Two paths are considered to be equivalent if they have the same parts.
94 95 96 |
# File 'library/general/src/lib/installation/autoinst_profile/element_path.rb', line 94 def ==(other) @parts == other.to_a end |
#join(*parts_or_path) ⇒ ElementPath
Returns a new path composed by the given parts
79 80 81 82 83 84 85 86 |
# File 'library/general/src/lib/installation/autoinst_profile/element_path.rb', line 79 def join(*parts_or_path) new_parts = parts_or_path.reduce([]) do |all, element| new_elements = element.respond_to?(:to_a) ? element.to_a : [element] all + new_elements end self.class.new(*(@parts + new_parts)) end |
#to_a ⇒ Array<Integer,String>
Returns the path parts
62 63 64 |
# File 'library/general/src/lib/installation/autoinst_profile/element_path.rb', line 62 def to_a @parts end |
#to_s ⇒ String
Returns a generic path (old AutoYaST path used in ask-lists)
105 106 107 |
# File 'library/general/src/lib/installation/autoinst_profile/element_path.rb', line 105 def to_s @parts.join(",") end |