Class: Option

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, description = "") ⇒ Option

Returns a new instance of Option



6
7
8
9
10
# File 'brew/Library/Homebrew/options.rb', line 6

def initialize(name, description = "")
  @name = name
  @flag = "--#{name}"
  @description = description
end

Instance Attribute Details

#descriptionObject (readonly)

Returns the value of attribute description



4
5
6
# File 'brew/Library/Homebrew/options.rb', line 4

def description
  @description
end

#flagObject (readonly)

Returns the value of attribute flag



4
5
6
# File 'brew/Library/Homebrew/options.rb', line 4

def flag
  @flag
end

#nameObject (readonly)

Returns the value of attribute name



4
5
6
# File 'brew/Library/Homebrew/options.rb', line 4

def name
  @name
end

Instance Method Details

#<=>(other) ⇒ Object



16
17
18
19
20
# File 'brew/Library/Homebrew/options.rb', line 16

def <=>(other)
  return unless other.is_a?(Option)

  name <=> other.name
end

#==(other) ⇒ Object Also known as: eql?



22
23
24
# File 'brew/Library/Homebrew/options.rb', line 22

def ==(other)
  instance_of?(other.class) && name == other.name
end

#hashObject



27
28
29
# File 'brew/Library/Homebrew/options.rb', line 27

def hash
  name.hash
end

#inspectObject



31
32
33
# File 'brew/Library/Homebrew/options.rb', line 31

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

#to_sObject



12
13
14
# File 'brew/Library/Homebrew/options.rb', line 12

def to_s
  flag
end