Spec-Zone.ru › Homebrew

Class: Options Private

Inherits:
Object
  • Object
  • Options
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

  • .create(array) ⇒ Options private
  • .dump_for_formula(formula) ⇒ void private

Instance Method Summary collapse

  • #&(other) ⇒ T.self_type private
  • #*(other) ⇒ String private
  • #+(other) ⇒ T.self_type private
  • #-(other) ⇒ T.self_type private
  • #<<(other) ⇒ T.self_type private
  • #as_flags ⇒ Array<String> private
  • #each(&block) ⇒ T.self_type private
  • #empty? ⇒ Boolean private
  • #freeze ⇒ T.self_type private
  • #include?(option) ⇒ Boolean private
  • #initialize(options = nil) ⇒ void constructor private
  • #initialize_dup(other) ⇒ void private
  • #to_a ⇒ Array<Option> private

    This is a workaround to enable alias to_ary to_a.

  • #to_ary ⇒ Object private
  • #|(other) ⇒ T.self_type private

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:

  • options (Enumerable<Option>, nil) (defaults to: nil)


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:

  • array (Array<String>, nil)

Returns:

  • (Options)


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:

  • formula (Formula)


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:

  • other (Enumerable<Option>)

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:

  • other (String)

Returns:

  • (String)


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:

  • other (Enumerable<Option>)

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:

  • other (Enumerable<Option>)

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:

  • other (Option)

Returns:

  • (T.self_type)


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

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

#as_flags ⇒ Array<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:

  • (Array<String>)


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

#freeze ⇒ 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.

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:

  • option (Option, String)

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:

  • other (Options)


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

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

#to_a ⇒ Array<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

Returns:

  • (Array<Option>)

See Also:

  • https://github.com/sorbet/sorbet/issues/2378#issuecomment-569474238


7
# File 'options.rbi', line 7

def to_a; end

#to_ary ⇒ Object

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:

  • other (Enumerable<Option>)

Returns:

  • (T.self_type)


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

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

© 2009–present Homebrew contributors
Licensed under the BSD 2-Clause License.
https://docs.brew.sh/rubydoc/Options.html

Spec-Zone.ru

Настройки Оффлайн Что нового Помощь О нас
Spec-Zone .ru
спецификации, руководства, описания, API