Class: Options Private

Inherits:
Object show all
Extended by:
T::Generic
Includes:
Enumerable
Defined in:
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:



98
99
100
101
# File 'options.rb', line 98

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:



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

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:



191
192
193
194
195
196
# File 'options.rb', line 191

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)


138
139
140
# File 'options.rb', line 138

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:



148
149
150
# File 'options.rb', line 148

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)


128
129
130
# File 'options.rb', line 128

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)


133
134
135
# File 'options.rb', line 133

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)


122
123
124
125
# File 'options.rb', line 122

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:



169
170
171
# File 'options.rb', line 169

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)


116
117
118
119
# File 'options.rb', line 116

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)


164
165
166
# File 'options.rb', line 164

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)


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

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)


174
175
176
# File 'options.rb', line 174

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:



104
105
106
107
# File 'options.rb', line 104

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.



178
# File 'options.rb', line 178

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)


143
144
145
# File 'options.rb', line 143

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