Class: Y2Issues::Location
- Inherits:
-
Object
- Object
- Y2Issues::Location
- Defined in:
- library/general/src/lib/y2issues/location.rb
Overview
Represent the location of an error
It can be a file, a section of an AutoYaST profile, etc. This class is rather open and its API might change once we know more about error reporting.
The concept of "location" is introduce to tell the user where to look for a problem and as a mechanism to group the issues.
A location is composed by three parts:
- type: whether the location is a file, an AutoYaST profile section, etc.
- path: location path (file path, AutoYaST profile path, etc.)
- id: it can be the file line, a key, an AutoYaST element name, etc. This element is optional.
Instance Attribute Summary collapse
-
#id ⇒ String?
readonly
Location ID within the path.
-
#path ⇒ String
readonly
Location path (a file path, an AutoYaST section path, and so on).
-
#type ⇒ String
readonly
Location type ("file", "autoyast", etc.).
Class Method Summary collapse
-
.parse(str) ⇒ Location
Parse a string and creates a location.
Instance Method Summary collapse
-
#==(other) ⇒ Boolean
(also: #eql?)
Determines whether two locations are the same.
-
#initialize(type, path, id = nil) ⇒ Location
constructor
A new instance of Location.
-
#to_s ⇒ String
Returns a string-based representation of the location.
Constructor Details
#initialize(type, path, id = nil) ⇒ Location
Returns a new instance of Location.
69 70 71 72 73 |
# File 'library/general/src/lib/y2issues/location.rb', line 69 def initialize(type, path, id = nil) @type = type @path = path @id = id end |
Instance Attribute Details
#id ⇒ String? (readonly)
Returns Location ID within the path.
40 41 42 |
# File 'library/general/src/lib/y2issues/location.rb', line 40 def id @id end |
#path ⇒ String (readonly)
Returns Location path (a file path, an AutoYaST section path, and so on).
38 39 40 |
# File 'library/general/src/lib/y2issues/location.rb', line 38 def path @path end |
#type ⇒ String (readonly)
Returns Location type ("file", "autoyast", etc.).
36 37 38 |
# File 'library/general/src/lib/y2issues/location.rb', line 36 def type @type end |
Class Method Details
.parse(str) ⇒ Location
Parse a string and creates a location
The string contains the type, the path and the id, separated by colons.
61 62 63 64 |
# File 'library/general/src/lib/y2issues/location.rb', line 61 def self.parse(str) type, path, id = str.split(":") new(type, path, id) end |
Instance Method Details
#==(other) ⇒ Boolean Also known as: eql?
Determines whether two locations are the same
87 88 89 |
# File 'library/general/src/lib/y2issues/location.rb', line 87 def ==(other) type == other.type && path == other.path && id == other.id end |
#to_s ⇒ String
Returns a string-based representation of the location
79 80 81 |
# File 'library/general/src/lib/y2issues/location.rb', line 79 def to_s [type, path, id].compact.join(":") end |