Class: UsageMod::Argument

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

Instance Method Summary collapse

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_typeObject (readonly)

Returns the value of attribute arg_type.



270
271
272
# File 'lib/Usage.rb', line 270

def arg_type
  @arg_type
end

#infiniteObject (readonly)

Returns the value of attribute infinite.



270
271
272
# File 'lib/Usage.rb', line 270

def infinite
  @infinite
end

#nameObject (readonly)

Returns the value of attribute name.



270
271
272
# File 'lib/Usage.rb', line 270

def name
  @name
end

#optionalObject (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

#hashObject

allow it to be used in a hash



282
283
284
# File 'lib/Usage.rb', line 282

def hash
  @name.hash
end

#to_sObject



293
294
295
# File 'lib/Usage.rb', line 293

def to_s
  "ARG:[#{@name}][#{@arg_type}][#{@infinite}]"
end