Class: Clio::Usage::Signature
- Inherits:
-
Object
- Object
- Clio::Usage::Signature
- 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
-
#arguments ⇒ Object
readonly
Returns the value of attribute arguments.
-
#command ⇒ Object
readonly
Returns the value of attribute command.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#signature ⇒ Object
readonly
Returns the value of attribute signature.
Instance Method Summary collapse
-
#initialize(c, a, o) ⇒ Signature
constructor
A new instance of Signature.
- #inspect ⇒ Object
- #method_missing(s, *a) ⇒ Object
- #parameters ⇒ Object
- #to_a ⇒ Object
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 /[?]$/ [s.chomp('?').to_sym] else [s.to_sym] end end |
Instance Attribute Details
#arguments ⇒ Object (readonly)
Returns the value of attribute arguments.
19 20 21 |
# File 'lib/clio/usage/signature.rb', line 19 def arguments @arguments end |
#command ⇒ Object (readonly)
Returns the value of attribute command.
18 19 20 |
# File 'lib/clio/usage/signature.rb', line 18 def command @command end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
20 21 22 |
# File 'lib/clio/usage/signature.rb', line 20 def @options end |
#signature ⇒ Object (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
#inspect ⇒ Object
29 |
# File 'lib/clio/usage/signature.rb', line 29 def inspect; "#<#{self.class}:" + @signature.inspect + ">"; end |
#parameters ⇒ Object
25 26 27 |
# File 'lib/clio/usage/signature.rb', line 25 def parameters @arguments + [@options] end |
#to_a ⇒ Object
23 |
# File 'lib/clio/usage/signature.rb', line 23 def to_a; @signature; end |