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.


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

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.


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

def self.create(array)
  new 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.


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

def self.dump_for_formula(f)
  f.options.sort_by(&:flag).each do |opt|
    puts "#{opt.flag}\n\t#{opt.description}"
  end
  puts "--devel\n\tInstall development version #{f.devel.version}" if f.devel
  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.


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

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.


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

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.


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

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.


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

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.


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

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.


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

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.


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

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)

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

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)

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

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.


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

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.


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

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