Class: GLI::CommandLineToken

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

Overview

Logical element of a command line, mostly so that subclasses can have similar initialization and interface

Direct Known Subclasses

Command, Switch

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(names, description, long_description = nil) ⇒ CommandLineToken

Returns a new instance of CommandLineToken.



10
11
12
13
14
# File 'lib/gli/command_line_token.rb', line 10

def initialize(names,description,long_description=nil)
  @description = description
  @long_description = long_description
  @name,@aliases,@names = parse_names(names)
end

Instance Attribute Details

#aliasesObject (readonly)

Returns the value of attribute aliases.



6
7
8
# File 'lib/gli/command_line_token.rb', line 6

def aliases
  @aliases
end

#descriptionObject (readonly)

Returns the value of attribute description.



7
8
9
# File 'lib/gli/command_line_token.rb', line 7

def description
  @description
end

#long_descriptionObject (readonly)

Returns the value of attribute long_description.



8
9
10
# File 'lib/gli/command_line_token.rb', line 8

def long_description
  @long_description
end

#nameObject (readonly)

Returns the value of attribute name.



5
6
7
# File 'lib/gli/command_line_token.rb', line 5

def name
  @name
end

Instance Method Details

#<=>(other) ⇒ Object



20
21
22
# File 'lib/gli/command_line_token.rb', line 20

def <=>(other)
  self.name.to_s <=> other.name.to_s
end

#usageObject



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

def usage
  all_forms
end