Class: TerminalOption

Inherits:
Object
  • Object
show all
Defined in:
lib/terrun.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, arg_num, help, usage) ⇒ TerminalOption


4
5
6
7
8
9
10
# File 'lib/terrun.rb', line 4

def initialize(name, arg_num, help, usage)
  @name = name
  @arg_num = arg_num
  @help = help
  @usage = usage
  @aliases = []
end

Instance Attribute Details

#aliasesObject

Returns the value of attribute aliases


2
3
4
# File 'lib/terrun.rb', line 2

def aliases
  @aliases
end

#arg_numObject

Returns the value of attribute arg_num


2
3
4
# File 'lib/terrun.rb', line 2

def arg_num
  @arg_num
end

#helpObject

Returns the value of attribute help


2
3
4
# File 'lib/terrun.rb', line 2

def help
  @help
end

#nameObject

Returns the value of attribute name


2
3
4
# File 'lib/terrun.rb', line 2

def name
  @name
end

#usageObject

Returns the value of attribute usage


2
3
4
# File 'lib/terrun.rb', line 2

def usage
  @usage
end

Instance Method Details

#add_alias(alias_name) ⇒ Object


12
13
14
# File 'lib/terrun.rb', line 12

def add_alias(alias_name)
  @aliases << alias_name
end

#has_alias?(alias_name) ⇒ Boolean


16
17
18
# File 'lib/terrun.rb', line 16

def has_alias?(alias_name)
  @name == alias_name || @aliases.include?(alias_name)
end

#to_sObject


20
21
22
23
24
25
# File 'lib/terrun.rb', line 20

def to_s
  result = name
  aliases.each { |a| result << " " + a }
  result << " " + usage
  result << "\n\t" + help
end