Class: Options Private

Inherits:
Object show all
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.

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Enumerable

#compact_blank, #exclude?

Constructor Details

#initialize(*args) ⇒ 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.

Returns a new instance of Options.



71
72
73
74
# File 'options.rb', line 71

def initialize(*args)
  # Ensure this is synced with `initialize_dup` and `freeze` (excluding simple objects like integers and booleans)
  @options = Set.new(*args)
end

Class Method Details

.create(array) ⇒ 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.



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

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

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



145
146
147
148
149
150
# File 'options.rb', line 145

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) ⇒ 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.



103
104
105
# File 'options.rb', line 103

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

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



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

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

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



95
96
97
# File 'options.rb', line 95

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

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



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

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

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



90
91
92
93
# File 'options.rb', line 90

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

#as_flagsObject

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.



125
126
127
# File 'options.rb', line 125

def as_flags
  map(&:flag)
end

#each(*args, &block) ⇒ 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.



86
87
88
# File 'options.rb', line 86

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


121
122
123
# File 'options.rb', line 121

def empty?
  @options.empty?
end

#freezeObject

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.



81
82
83
84
# File 'options.rb', line 81

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.

Returns:

  • (Boolean)


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

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

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



76
77
78
79
# File 'options.rb', line 76

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.



133
# File 'options.rb', line 133

alias to_ary to_a

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



107
108
109
# File 'options.rb', line 107

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