Class: PATH Private
- Extended by:
- Forwardable
- Includes:
- Enumerable
- Defined in:
- PATH.rb
Overview
This class is part of a private API. This class may only be used in the Homebrew/brew repository. Third parties should avoid using this class if possible, as it may be removed or changed without warning.
Representation of a *PATH
environment variable.
Instance Method Summary collapse
-
#==(other) ⇒ Boolean
private
-
#append(*paths) ⇒ T.self_type
private
-
#empty? ⇒ Boolean
private
-
#existing ⇒ T.self_type?
private
-
#initialize(*paths) ⇒ PATH
constructor
private
A new instance of PATH.
-
#insert(index, *paths) ⇒ T.self_type
private
-
#prepend(*paths) ⇒ T.self_type
private
-
#reject(&block) ⇒ T.self_type
private
-
#select(&block) ⇒ T.self_type
private
-
#to_ary ⇒ Array<String>
(also: #to_a)
private
-
#to_str ⇒ String
(also: #to_s)
private
Constructor Details
#initialize(*paths) ⇒ PATH
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
Returns a new instance of PATH.
22 23 24 |
# File 'PATH.rb', line 22 def initialize(*paths) @paths = parse(paths) end |
Instance Method Details
#==(other) ⇒ Boolean
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
67 68 69 70 71 |
# File 'PATH.rb', line 67 def ==(other) (other.respond_to?(:to_ary) && to_ary == other.to_ary) || (other.respond_to?(:to_str) && to_str == other.to_str) || false end |
#append(*paths) ⇒ T.self_type
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
33 34 35 36 |
# File 'PATH.rb', line 33 def append(*paths) @paths = parse(@paths + paths) self end |
#empty? ⇒ Boolean
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
74 75 76 |
# File 'PATH.rb', line 74 def empty? @paths.empty? end |
#existing ⇒ T.self_type?
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
79 80 81 82 83 |
# File 'PATH.rb', line 79 def existing existing_path = select(&File.method(:directory?)) # return nil instead of empty PATH, to unset environment variables existing_path unless existing_path.empty? end |
#insert(index, *paths) ⇒ T.self_type
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
39 40 41 42 |
# File 'PATH.rb', line 39 def insert(index, *paths) @paths = parse(@paths.insert(index, *paths)) self end |
#prepend(*paths) ⇒ T.self_type
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
27 28 29 30 |
# File 'PATH.rb', line 27 def prepend(*paths) @paths = parse(paths + @paths) self end |
#reject(&block) ⇒ T.self_type
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
50 51 52 |
# File 'PATH.rb', line 50 def reject(&block) self.class.new(@paths.reject(&block)) end |
#select(&block) ⇒ T.self_type
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
45 46 47 |
# File 'PATH.rb', line 45 def select(&block) self.class.new(@paths.select(&block)) end |
#to_ary ⇒ Array<String> Also known as: to_a
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
55 56 57 |
# File 'PATH.rb', line 55 def to_ary @paths.dup.to_ary end |
#to_str ⇒ String Also known as: to_s
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
61 62 63 |
# File 'PATH.rb', line 61 def to_str @paths.join(File::PATH_SEPARATOR) end |