Class: Option

Inherits:
Object
  • Object
show all
Defined in:
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 '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 'Library/Homebrew/options.rb', line 4

def description
  @description
end

#flagObject (readonly)

Returns the value of attribute flag



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

def flag
  @flag
end

#nameObject (readonly)

Returns the value of attribute name



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

def name
  @name
end

Instance Method Details

#<=>(other) ⇒ Object



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

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

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



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

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

#hashObject



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

def hash
  name.hash
end

#inspectObject



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

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

#to_sObject



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

def to_s
  flag
end