Class: Clio::Usage::Signature

Inherits:
Object
  • Object
show all
Defined in:
lib/clio/usage/signature.rb

Overview

Command Signature

Used by the Usage::Parser as the end result of parsing a Usage::Command.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(c, a, o) ⇒ Signature

Returns a new instance of Signature.



11
12
13
14
15
16
# File 'lib/clio/usage/signature.rb', line 11

def initialize(c, a, o)
  @signature  = [c, a, o]
  @command    = c
  @arguments  = a
  @options    = o
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(s, *a) ⇒ Object



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/clio/usage/signature.rb', line 32

def method_missing(s, *a)
  s = s.to_s
  case s
  #when /[=]$/
  #  n = s.chomp('=')
  #  usage.option(n).type(*a)
  #  #parser.parse
  #  res = parser.options[n.to_sym]
  #when /[!]$/
  #  n = s.chomp('!')
  #  res = parser.parse
  when /[?]$/
    options[s.chomp('?').to_sym]
  else
    options[s.to_sym]
  end
end

Instance Attribute Details

#argumentsObject (readonly)

Returns the value of attribute arguments.



19
20
21
# File 'lib/clio/usage/signature.rb', line 19

def arguments
  @arguments
end

#commandObject (readonly)

Returns the value of attribute command.



18
19
20
# File 'lib/clio/usage/signature.rb', line 18

def command
  @command
end

#optionsObject (readonly)

Returns the value of attribute options.



20
21
22
# File 'lib/clio/usage/signature.rb', line 20

def options
  @options
end

#signatureObject (readonly)

Returns the value of attribute signature.



21
22
23
# File 'lib/clio/usage/signature.rb', line 21

def signature
  @signature
end

Instance Method Details

#inspectObject



29
# File 'lib/clio/usage/signature.rb', line 29

def inspect; "#<#{self.class}:" + @signature.inspect + ">"; end

#parametersObject



25
26
27
# File 'lib/clio/usage/signature.rb', line 25

def parameters
  @arguments + [@options]
end

#to_aObject



23
# File 'lib/clio/usage/signature.rb', line 23

def to_a; @signature; end