Class: PATH Private

Inherits:
Object show all
Extended by:
Forwardable, T::Generic
Includes:
Enumerable
Defined in:
PATH.rb,
sorbet/rbi/dsl/path.rbi

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.

Constant Summary collapse

Elem =

This constant is part of a private API. This constant may only be used in the Homebrew/brew repository. Third parties should avoid using this constant if possible, as it may be removed or changed without warning.

type_member(:out) { { fixed: String } }

Instance Method Summary collapse

Methods included from Enumerable

#compact_blank, #exclude?

Constructor Details

#initialize(*paths) ⇒ void

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)


20
21
22
# File 'PATH.rb', line 20

def initialize(*paths)
  @paths = T.let(parse(paths), T::Array[String])
end

Instance Method Details

#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)


31
32
33
34
# File 'PATH.rb', line 31

def append(*paths)
  @paths = parse(@paths + paths)
  self
end

#each(*args, &block) ⇒ T.untyped

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:

  • args (T.untyped)
  • block (T.untyped)

Returns:

  • (T.untyped)


10
# File 'sorbet/rbi/dsl/path.rbi', line 10

def each(*args, &block); 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)


74
75
76
# File 'PATH.rb', line 74

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)


79
80
81
82
83
# File 'PATH.rb', line 79

def existing
  existing_path = select { File.directory?(_1) }
  # 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)


37
38
39
40
# File 'PATH.rb', line 37

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)


25
26
27
28
# File 'PATH.rb', line 25

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)


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

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)


43
44
45
# File 'PATH.rb', line 43

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:



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

def to_ary
  @paths.dup.to_ary
end

#to_strString

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:



59
60
61
# File 'PATH.rb', line 59

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