Class: Clio::Usage::Argument
- Inherits:
-
Object
- Object
- Clio::Usage::Argument
- Defined in:
- lib/clio/usage/argument.rb
Overview
Usage Argument
TODO: Should argument have name in addition to type?
Instance Attribute Summary collapse
-
#help(string = nil) ⇒ Object
readonly
Specify help text for argument.
-
#splat(true_or_false = nil) ⇒ Object
readonly
Returns the value of attribute splat.
-
#type(string = nil) ⇒ Object
readonly
Specify the type of the argument.
Instance Method Summary collapse
-
#initialize(type, &block) ⇒ Argument
constructor
New Argument.
- #initialize_copy(o) ⇒ Object
- #inspect ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(type, &block) ⇒ Argument
New Argument.
16 17 18 19 20 21 22 |
# File 'lib/clio/usage/argument.rb', line 16 def initialize(type, &block) @type = type #@name = type.downcase if type.upcase != type @splat = false @help = '' instance_eval(&block) if block end |
Instance Attribute Details
#help(string = nil) ⇒ Object (readonly)
Specify help text for argument.
62 63 64 |
# File 'lib/clio/usage/argument.rb', line 62 def help @help end |
#splat(true_or_false = nil) ⇒ Object (readonly)
Returns the value of attribute splat.
13 14 15 |
# File 'lib/clio/usage/argument.rb', line 13 def splat @splat end |
#type(string = nil) ⇒ Object (readonly)
Specify the type of the argument. This is an arbitrary description of the type. The value given is converted to uppercase.
arg.type('file')
arg.type #=> 'FILE'
11 12 13 |
# File 'lib/clio/usage/argument.rb', line 11 def type @type end |
Instance Method Details
#initialize_copy(o) ⇒ Object
25 26 27 28 29 |
# File 'lib/clio/usage/argument.rb', line 25 def initialize_copy(o) #@name = o.name.dup @type = o.type.dup @help = o.help.dup end |
#inspect ⇒ Object
73 74 75 76 77 78 79 |
# File 'lib/clio/usage/argument.rb', line 73 def inspect to_s #s = "<#{name}" #s << ":#{type.inspect}" if type #s << ">" #s end |
#to_s ⇒ Object
67 68 69 70 71 |
# File 'lib/clio/usage/argument.rb', line 67 def to_s s = "<#{type}" s << (splat ? "...>" : ">") s end |