Class: GLI::CommandLineToken

Inherits:
Object
  • Object
show all
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

Command, Switch

Instance Attribute Summary (collapse)

Instance Method Summary (collapse)

Constructor Details

- (CommandLineToken) initialize(names, description, long_description = nil)

:ndoc:



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

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

Instance Attribute Details

- (Object) aliases (readonly)

:ndoc:



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

def aliases
  @aliases
end

- (Object) description (readonly)

:ndoc:



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

def description
  @description
end

- (Object) long_description (readonly)

:ndoc:



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

def long_description
  @long_description
end

- (Object) name (readonly)

:ndoc:



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

def name
  @name
end

Instance Method Details

- (Object) <=>(other)

Sort based on name



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

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

- (Object) usage

:nodoc:



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

def usage #:nodoc:
  all_forms
end