Class: Options Private

Inherits:
Object show all
Extended by:
T::Generic
Includes:
Enumerable
Defined in:
options/options.rb,
options.rbi

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.

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: Option } }

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Enumerable

#compact_blank, #exclude?

Constructor Details

#initialize(options = nil) ⇒ 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:



17
18
19
20
# File 'options/options.rb', line 17

def initialize(options = nil)
  # Ensure this is synced with `initialize_dup` and `freeze` (excluding simple objects like integers and booleans)
  @options = T.let(Set.new(options), T::Set[Option])
end

Class Method Details

.create(array) ⇒ Options

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:

Returns:



12
13
14
# File 'options/options.rb', line 12

def self.create(array)
  new Array(array).map { |e| Option.new(e[/^--([^=]+=?)(.+)?$/, 1] || e) }
end

.dump_for_formula(formula) ⇒ 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.

This method returns an undefined value.

Parameters:



110
111
112
113
114
115
# File 'options/options.rb', line 110

def self.dump_for_formula(formula)
  formula.options.sort_by(&:flag).each do |opt|
    puts "#{opt.flag}\n\t#{opt.description}"
  end
  puts "--HEAD\n\tInstall HEAD version" if formula.head
end

Instance Method Details

#&(other) ⇒ 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:

Returns:

  • (T.self_type)


57
58
59
# File 'options/options.rb', line 57

def &(other)
  self.class.new(@options & other)
end

#*(other) ⇒ String

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:

Returns:



67
68
69
# File 'options/options.rb', line 67

def *(other)
  @options.to_a * other
end

#+(other) ⇒ 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:

Returns:

  • (T.self_type)


47
48
49
# File 'options/options.rb', line 47

def +(other)
  self.class.new(@options + other)
end

#-(other) ⇒ 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:

Returns:

  • (T.self_type)


52
53
54
# File 'options/options.rb', line 52

def -(other)
  self.class.new(@options - other)
end

#<<(other) ⇒ 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:

Returns:

  • (T.self_type)


41
42
43
44
# File 'options/options.rb', line 41

def <<(other)
  @options << other
  self
end

#as_flagsArray<String>

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:



88
89
90
# File 'options/options.rb', line 88

def as_flags
  map(&:flag)
end

#each(&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: Option).returns(BasicObject))

Returns:

  • (T.self_type)


35
36
37
38
# File 'options/options.rb', line 35

def each(&block)
  @options.each(&block)
  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)


83
84
85
# File 'options/options.rb', line 83

def empty?
  @options.empty?
end

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


29
30
31
32
# File 'options/options.rb', line 29

def freeze
  @options.dup
  super
end

#include?(option) ⇒ 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:

Returns:

  • (Boolean)


93
94
95
# File 'options/options.rb', line 93

def include?(option)
  any? { |opt| opt == option || opt.name == option || opt.flag == option }
end

#initialize_dup(other) ⇒ 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.

This method returns an undefined value.

Parameters:



23
24
25
26
# File 'options/options.rb', line 23

def initialize_dup(other)
  super
  @options = @options.dup
end

#to_aArray<Option>

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.

This is a workaround to enable alias to_ary to_a



7
# File 'options.rbi', line 7

def to_a; end

#to_aryObject

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.



97
# File 'options/options.rb', line 97

alias to_ary to_a

#|(other) ⇒ 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:

Returns:

  • (T.self_type)


62
63
64
# File 'options/options.rb', line 62

def |(other)
  self.class.new(@options | other)
end