Class: GLI::CommandLineToken
- Inherits:
-
Object
- Object
- GLI::CommandLineToken
- Defined in:
- lib/gli/command_line_token.rb
Overview
Abstract base class for a logical element of a command line, mostly so that subclasses can have similar initialization and interface
Direct Known Subclasses
Instance Attribute Summary collapse
-
#aliases ⇒ Object
readonly
:nodoc:.
-
#description ⇒ Object
readonly
:nodoc:.
-
#long_description ⇒ Object
readonly
:nodoc:.
-
#name ⇒ Object
readonly
:nodoc:.
Instance Method Summary collapse
-
#<=>(other) ⇒ Object
Sort based on primary name.
-
#initialize(names, description, long_description = nil) ⇒ CommandLineToken
constructor
:nodoc:.
-
#names_and_aliases ⇒ Object
Array of the name and aliases, as string.
Constructor Details
#initialize(names, description, long_description = nil) ⇒ CommandLineToken
:nodoc:
10 11 12 13 14 |
# File 'lib/gli/command_line_token.rb', line 10 def initialize(names,description,long_description=nil) #:nodoc: @description = description @long_description = long_description @name,@aliases,@names = parse_names(names) end |
Instance Attribute Details
#aliases ⇒ Object (readonly)
:nodoc:
6 7 8 |
# File 'lib/gli/command_line_token.rb', line 6 def aliases @aliases end |
#description ⇒ Object (readonly)
:nodoc:
7 8 9 |
# File 'lib/gli/command_line_token.rb', line 7 def description @description end |
#long_description ⇒ Object (readonly)
:nodoc:
8 9 10 |
# File 'lib/gli/command_line_token.rb', line 8 def long_description @long_description end |
#name ⇒ Object (readonly)
:nodoc:
5 6 7 |
# File 'lib/gli/command_line_token.rb', line 5 def name @name end |
Instance Method Details
#<=>(other) ⇒ Object
Sort based on primary name
17 18 19 |
# File 'lib/gli/command_line_token.rb', line 17 def <=>(other) self.name.to_s <=> other.name.to_s end |
#names_and_aliases ⇒ Object
Array of the name and aliases, as string
22 23 24 |
# File 'lib/gli/command_line_token.rb', line 22 def names_and_aliases [self.name,self.aliases].flatten.compact.map(&:to_s) end |