Class: UsageMod::Argument
- Inherits:
-
Object
- Object
- UsageMod::Argument
- Defined in:
- lib/Usage.rb
Overview
This class describes arguments (not options) which can include:
-
the name of the argument
-
its type (default is String)
-
whether it is an infinite argument or not
-
whether it is optional or not
Constant Summary collapse
- SINGLE =
1- INFINITE =
2
Instance Attribute Summary collapse
-
#arg_type ⇒ Object
readonly
Returns the value of attribute arg_type.
-
#infinite ⇒ Object
readonly
Returns the value of attribute infinite.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#optional ⇒ Object
readonly
Returns the value of attribute optional.
Instance Method Summary collapse
-
#==(other) ⇒ Object
allow it to be compared with other Argument objects.
-
#hash ⇒ Object
allow it to be used in a hash.
-
#initialize(name, arg_type, infinite, optional = false) ⇒ Argument
constructor
A new instance of Argument.
- #to_s ⇒ Object
Constructor Details
#initialize(name, arg_type, infinite, optional = false) ⇒ Argument
Returns a new instance of Argument.
272 273 274 275 276 277 |
# File 'lib/Usage.rb', line 272 def initialize(name, arg_type, infinite, optional=false) @name = name @arg_type = arg_type @infinite = infinite @optional = optional end |
Instance Attribute Details
#arg_type ⇒ Object (readonly)
Returns the value of attribute arg_type.
270 271 272 |
# File 'lib/Usage.rb', line 270 def arg_type @arg_type end |
#infinite ⇒ Object (readonly)
Returns the value of attribute infinite.
270 271 272 |
# File 'lib/Usage.rb', line 270 def infinite @infinite end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
270 271 272 |
# File 'lib/Usage.rb', line 270 def name @name end |
#optional ⇒ Object (readonly)
Returns the value of attribute optional.
270 271 272 |
# File 'lib/Usage.rb', line 270 def optional @optional end |
Instance Method Details
#==(other) ⇒ Object
allow it to be compared with other Argument objects
289 290 291 |
# File 'lib/Usage.rb', line 289 def ==(other) @name = other.name end |
#hash ⇒ Object
allow it to be used in a hash
282 283 284 |
# File 'lib/Usage.rb', line 282 def hash @name.hash end |
#to_s ⇒ Object
293 294 295 |
# File 'lib/Usage.rb', line 293 def to_s "ARG:[#{@name}][#{@arg_type}][#{@infinite}]" end |