Class: PATH Private

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

Represention of a *PATH environment variable.

Instance Method Summary collapse

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.



24
25
26
# File 'PATH.rb', line 24

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.

Parameters:

  • other (T.untyped)

Returns:

  • (Boolean)


69
70
71
72
73
# File 'PATH.rb', line 69

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.

Parameters:

  • paths (Elements)

Returns:

  • (T.self_type)


35
36
37
38
# File 'PATH.rb', line 35

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.

Returns:

  • (Boolean)


76
77
78
# File 'PATH.rb', line 76

def empty?
  @paths.empty?
end

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

Returns:

  • (T.self_type, nil)


81
82
83
84
85
# File 'PATH.rb', line 81

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.

Parameters:

  • index (Integer)
  • paths (Elements)

Returns:

  • (T.self_type)


41
42
43
44
# File 'PATH.rb', line 41

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.

Parameters:

  • paths (Elements)

Returns:

  • (T.self_type)


29
30
31
32
# File 'PATH.rb', line 29

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.

Parameters:

  • block (T.proc.params(arg0: String).returns(T::Boolean))

Returns:

  • (T.self_type)


52
53
54
# File 'PATH.rb', line 52

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.

Parameters:

  • block (T.proc.params(arg0: String).returns(T::Boolean))

Returns:

  • (T.self_type)


47
48
49
# File 'PATH.rb', line 47

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

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

Returns:



57
58
59
# File 'PATH.rb', line 57

def to_ary
  @paths.dup.to_ary
end

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

Returns:



63
64
65
# File 'PATH.rb', line 63

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