Class: PATH Private
- Inherits:
-
Object
- Object
- PATH
- Extended by:
- Forwardable, T::Sig
- Includes:
- Enumerable
- Defined in:
- Library/Homebrew/PATH.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.
Represention of a *PATH
environment variable.
Instance Method Summary collapse
- #==(other) ⇒ Object private
- #append(*paths) ⇒ Object private
- #empty? ⇒ Boolean private
- #existing ⇒ Object private
-
#initialize(*paths) ⇒ PATH
constructor
private
A new instance of PATH.
- #insert(index, *paths) ⇒ Object private
- #prepend(*paths) ⇒ Object private
- #reject(&block) ⇒ Object private
- #select(&block) ⇒ Object private
- #to_ary ⇒ Object (also: #to_a) private
- #to_str ⇒ Object (also: #to_s) private
Constructor Details
#initialize(*paths) ⇒ PATH
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 PATH.
24 25 26 |
# File 'Library/Homebrew/PATH.rb', line 24 def initialize(*paths) @paths = parse(paths) end |
Instance Method Details
#==(other) ⇒ 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 72 73 74 75 76 77 |
# File 'Library/Homebrew/PATH.rb', line 69 def ==(other) if other.respond_to?(:to_ary) && to_ary == other.to_ary true elsif other.respond_to?(:to_str) && to_str == other.to_str true else false end end |
#append(*paths) ⇒ 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.
35 36 37 38 |
# File 'Library/Homebrew/PATH.rb', line 35 def append(*paths) @paths = parse(@paths + paths) self end |
#empty? ⇒ Boolean
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 |
# File 'Library/Homebrew/PATH.rb', line 80 def empty? @paths.empty? end |
#existing ⇒ 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.
85 86 87 88 89 |
# File 'Library/Homebrew/PATH.rb', line 85 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) ⇒ 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.
41 42 43 44 |
# File 'Library/Homebrew/PATH.rb', line 41 def insert(index, *paths) @paths = parse(@paths.insert(index, *paths)) self end |
#prepend(*paths) ⇒ 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.
29 30 31 32 |
# File 'Library/Homebrew/PATH.rb', line 29 def prepend(*paths) @paths = parse(paths + @paths) self end |
#reject(&block) ⇒ 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.
52 53 54 |
# File 'Library/Homebrew/PATH.rb', line 52 def reject(&block) self.class.new(@paths.reject(&block)) end |
#select(&block) ⇒ 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.
47 48 49 |
# File 'Library/Homebrew/PATH.rb', line 47 def select(&block) self.class.new(@paths.select(&block)) end |
#to_ary ⇒ Object Also known as: to_a
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.
57 58 59 |
# File 'Library/Homebrew/PATH.rb', line 57 def to_ary @paths.dup.to_ary end |
#to_str ⇒ Object Also known as: to_s
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.
63 64 65 |
# File 'Library/Homebrew/PATH.rb', line 63 def to_str @paths.join(File::PATH_SEPARATOR) end |