Class: Git::ConfigEntryInfo
- Inherits:
-
Data
- Object
- Data
- Git::ConfigEntryInfo
- Defined in:
- lib/git/config_entry_info.rb
Overview
Represents a single Git configuration entry
Returned by Configuring read operations such as Git::Configuring#config_get, Git::Configuring#config_get_all, Git::Configuring#config_list, and their related methods.
Instance Attribute Summary collapse
-
#key ⇒ Object
readonly
Returns the value of attribute key.
-
#origin ⇒ Object
readonly
Returns the value of attribute origin.
-
#scope ⇒ Object
readonly
Returns the value of attribute scope.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Instance Method Summary collapse
-
#section ⇒ String
Returns the section component of the key (everything before the first dot).
-
#subsection ⇒ String
Returns the subsection component of the key (everything between the first and last dot).
-
#variable ⇒ String
Returns the variable component of the key (everything after the last dot).
Instance Attribute Details
#key ⇒ Object (readonly)
Returns the value of attribute key
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 |
# File 'lib/git/config_entry_info.rb', line 58 ConfigEntryInfo = Data.define(:scope, :origin, :key, :value) do # Returns the section component of the key (everything before the first dot) # # Returns an empty string when the key contains no dot. # # @example Section component of a dotted key # entry.section # => "remote" # # @return [String] the section name, or an empty string when the key has no dot # def section = first_dot ? key[0...first_dot] : '' # Returns the subsection component of the key (everything between the first and last dot) # # Returns an empty string when the key has zero or one dot (no subsection). # # @example Subsection component of a dotted key # entry.subsection # => "origin" # # @return [String] the subsection name, or an empty string when there is no subsection # def subsection = first_dot && first_dot != last_dot ? key[(first_dot + 1)...last_dot] : '' # Returns the variable component of the key (everything after the last dot) # # Returns the full key when the key contains no dot. # # @example Variable component of a dotted key # entry.variable # => "url" # # @return [String] the variable name (everything after the last dot) # def variable = last_dot ? key[(last_dot + 1)..] : key private # Returns the index of the first dot in the key, or nil if none exists # # @return [Integer, nil] the zero-based index of the first dot, or `nil` # def first_dot = key.index('.') # Returns the index of the last dot in the key, or nil if none exists # # @return [Integer, nil] the zero-based index of the last dot, or `nil` # def last_dot = key.rindex('.') end |
#origin ⇒ Object (readonly)
Returns the value of attribute origin
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 |
# File 'lib/git/config_entry_info.rb', line 58 ConfigEntryInfo = Data.define(:scope, :origin, :key, :value) do # Returns the section component of the key (everything before the first dot) # # Returns an empty string when the key contains no dot. # # @example Section component of a dotted key # entry.section # => "remote" # # @return [String] the section name, or an empty string when the key has no dot # def section = first_dot ? key[0...first_dot] : '' # Returns the subsection component of the key (everything between the first and last dot) # # Returns an empty string when the key has zero or one dot (no subsection). # # @example Subsection component of a dotted key # entry.subsection # => "origin" # # @return [String] the subsection name, or an empty string when there is no subsection # def subsection = first_dot && first_dot != last_dot ? key[(first_dot + 1)...last_dot] : '' # Returns the variable component of the key (everything after the last dot) # # Returns the full key when the key contains no dot. # # @example Variable component of a dotted key # entry.variable # => "url" # # @return [String] the variable name (everything after the last dot) # def variable = last_dot ? key[(last_dot + 1)..] : key private # Returns the index of the first dot in the key, or nil if none exists # # @return [Integer, nil] the zero-based index of the first dot, or `nil` # def first_dot = key.index('.') # Returns the index of the last dot in the key, or nil if none exists # # @return [Integer, nil] the zero-based index of the last dot, or `nil` # def last_dot = key.rindex('.') end |
#scope ⇒ Object (readonly)
Returns the value of attribute scope
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 |
# File 'lib/git/config_entry_info.rb', line 58 ConfigEntryInfo = Data.define(:scope, :origin, :key, :value) do # Returns the section component of the key (everything before the first dot) # # Returns an empty string when the key contains no dot. # # @example Section component of a dotted key # entry.section # => "remote" # # @return [String] the section name, or an empty string when the key has no dot # def section = first_dot ? key[0...first_dot] : '' # Returns the subsection component of the key (everything between the first and last dot) # # Returns an empty string when the key has zero or one dot (no subsection). # # @example Subsection component of a dotted key # entry.subsection # => "origin" # # @return [String] the subsection name, or an empty string when there is no subsection # def subsection = first_dot && first_dot != last_dot ? key[(first_dot + 1)...last_dot] : '' # Returns the variable component of the key (everything after the last dot) # # Returns the full key when the key contains no dot. # # @example Variable component of a dotted key # entry.variable # => "url" # # @return [String] the variable name (everything after the last dot) # def variable = last_dot ? key[(last_dot + 1)..] : key private # Returns the index of the first dot in the key, or nil if none exists # # @return [Integer, nil] the zero-based index of the first dot, or `nil` # def first_dot = key.index('.') # Returns the index of the last dot in the key, or nil if none exists # # @return [Integer, nil] the zero-based index of the last dot, or `nil` # def last_dot = key.rindex('.') end |
#value ⇒ Object (readonly)
Returns the value of attribute value
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 |
# File 'lib/git/config_entry_info.rb', line 58 ConfigEntryInfo = Data.define(:scope, :origin, :key, :value) do # Returns the section component of the key (everything before the first dot) # # Returns an empty string when the key contains no dot. # # @example Section component of a dotted key # entry.section # => "remote" # # @return [String] the section name, or an empty string when the key has no dot # def section = first_dot ? key[0...first_dot] : '' # Returns the subsection component of the key (everything between the first and last dot) # # Returns an empty string when the key has zero or one dot (no subsection). # # @example Subsection component of a dotted key # entry.subsection # => "origin" # # @return [String] the subsection name, or an empty string when there is no subsection # def subsection = first_dot && first_dot != last_dot ? key[(first_dot + 1)...last_dot] : '' # Returns the variable component of the key (everything after the last dot) # # Returns the full key when the key contains no dot. # # @example Variable component of a dotted key # entry.variable # => "url" # # @return [String] the variable name (everything after the last dot) # def variable = last_dot ? key[(last_dot + 1)..] : key private # Returns the index of the first dot in the key, or nil if none exists # # @return [Integer, nil] the zero-based index of the first dot, or `nil` # def first_dot = key.index('.') # Returns the index of the last dot in the key, or nil if none exists # # @return [Integer, nil] the zero-based index of the last dot, or `nil` # def last_dot = key.rindex('.') end |
Instance Method Details
#section ⇒ String
Returns the section component of the key (everything before the first dot)
Returns an empty string when the key contains no dot.
68 |
# File 'lib/git/config_entry_info.rb', line 68 def section = first_dot ? key[0...first_dot] : '' |
#subsection ⇒ String
Returns the subsection component of the key (everything between the first and last dot)
Returns an empty string when the key has zero or one dot (no subsection).
79 |
# File 'lib/git/config_entry_info.rb', line 79 def subsection = first_dot && first_dot != last_dot ? key[(first_dot + 1)...last_dot] : '' |
#variable ⇒ String
Returns the variable component of the key (everything after the last dot)
Returns the full key when the key contains no dot.
90 |
# File 'lib/git/config_entry_info.rb', line 90 def variable = last_dot ? key[(last_dot + 1)..] : key |