Class: TerminalOption
- Inherits:
-
Object
- Object
- TerminalOption
- Defined in:
- lib/terrun.rb
Instance Attribute Summary collapse
-
#aliases ⇒ Object
Returns the value of attribute aliases.
-
#arg_num ⇒ Object
Returns the value of attribute arg_num.
-
#help ⇒ Object
Returns the value of attribute help.
-
#name ⇒ Object
Returns the value of attribute name.
-
#usage ⇒ Object
Returns the value of attribute usage.
Instance Method Summary collapse
- #add_alias(alias_name) ⇒ Object
- #has_alias?(alias_name) ⇒ Boolean
-
#initialize(name, arg_num, help, usage) ⇒ TerminalOption
constructor
A new instance of TerminalOption.
- #to_s ⇒ Object
Constructor Details
#initialize(name, arg_num, help, usage) ⇒ TerminalOption
Returns a new instance of 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
#aliases ⇒ Object
Returns the value of attribute aliases.
2 3 4 |
# File 'lib/terrun.rb', line 2 def aliases @aliases end |
#arg_num ⇒ Object
Returns the value of attribute arg_num.
2 3 4 |
# File 'lib/terrun.rb', line 2 def arg_num @arg_num end |
#help ⇒ Object
Returns the value of attribute help.
2 3 4 |
# File 'lib/terrun.rb', line 2 def help @help end |
#name ⇒ Object
Returns the value of attribute name.
2 3 4 |
# File 'lib/terrun.rb', line 2 def name @name end |
#usage ⇒ Object
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_s ⇒ Object
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 |