Class: PATH Private

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
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

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.


12
13
14
# File 'Library/Homebrew/PATH.rb', line 12

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.


49
50
51
52
53
54
55
56
57
58
59
# File 'Library/Homebrew/PATH.rb', line 49

def ==(other)
  if other.respond_to?(:to_ary)
    return true if to_ary == other.to_ary
  end

  if other.respond_to?(:to_str)
    return true if to_str == other.to_str
  end

  false
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.


21
22
23
24
# File 'Library/Homebrew/PATH.rb', line 21

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.

Returns:

  • (Boolean)

61
62
63
# File 'Library/Homebrew/PATH.rb', line 61

def empty?
  @paths.empty?
end

#existingObject

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.


65
66
67
68
69
# File 'Library/Homebrew/PATH.rb', line 65

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.


26
27
28
29
# File 'Library/Homebrew/PATH.rb', line 26

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.


16
17
18
19
# File 'Library/Homebrew/PATH.rb', line 16

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.


35
36
37
# File 'Library/Homebrew/PATH.rb', line 35

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.


31
32
33
# File 'Library/Homebrew/PATH.rb', line 31

def select(&block)
  self.class.new(@paths.select(&block))
end

#to_aryObject 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.


39
40
41
# File 'Library/Homebrew/PATH.rb', line 39

def to_ary
  @paths.dup.to_ary
end

#to_strObject 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.


44
45
46
# File 'Library/Homebrew/PATH.rb', line 44

def to_str
  @paths.join(File::PATH_SEPARATOR)
end