Class: Options Private

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
Library/Homebrew/options.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

A collection of formula options.

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ Options

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Options.


75
76
77
# File 'Library/Homebrew/options.rb', line 75

def initialize(*args)
  @options = Set.new(*args)
end

Class Method Details

.create(array) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.


71
72
73
# File 'Library/Homebrew/options.rb', line 71

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

.dump_for_formula(f) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.


126
127
128
129
130
131
# File 'Library/Homebrew/options.rb', line 126

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

Instance Method Details

#&(other) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.


96
97
98
# File 'Library/Homebrew/options.rb', line 96

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

#*(other) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.


104
105
106
# File 'Library/Homebrew/options.rb', line 104

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

#+(other) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.


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

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

#-(other) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.


92
93
94
# File 'Library/Homebrew/options.rb', line 92

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

#<<(other) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.


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

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

#as_flagsObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.


112
113
114
# File 'Library/Homebrew/options.rb', line 112

def as_flags
  map(&:flag)
end

#each(*args, &block) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.


79
80
81
# File 'Library/Homebrew/options.rb', line 79

def each(*args, &block)
  @options.each(*args, &block)
end

#empty?Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)

108
109
110
# File 'Library/Homebrew/options.rb', line 108

def empty?
  @options.empty?
end

#include?(o) ⇒ Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)

116
117
118
# File 'Library/Homebrew/options.rb', line 116

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

#inspectObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.


122
123
124
# File 'Library/Homebrew/options.rb', line 122

def inspect
  "#<#{self.class.name}: #{to_a.inspect}>"
end

#|(other) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.


100
101
102
# File 'Library/Homebrew/options.rb', line 100

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