class CLASP::Flag
A class that represents the specification for a command-line flag
Attributes
(Proc) The procedure
The flag's aliases array
The flag's extras
The flag's help string
The flag's name string
Public Class Methods
An instance of FlagSpecification
that provides default '–help' information
If you wish to specify extras
or attach a block, you may do so
# File lib/clasp/specifications.rb, line 188 def self.Help(extras = nil, &blk) h = @@Help_ if extras || blk return self.new(h.name, h.aliases, h.help, extras, &blk) end h end
An instance of FlagSpecification
that provides default '–version' information
If you wish to specify extras
or attach a block, you may do so
# File lib/clasp/specifications.rb, line 203 def self.Version(extras = nil, &blk) h = @@Version_ if extras || blk return self.new(h.name, h.aliases, h.help, extras, &blk) end h end
Creates a FlagSpecification
instance from the given name, aliases, and help
Signature¶ ↑
-
Parameters
-
name
(String
) The name, or long-form, of the flag -
aliases
(Array
) 0 or more strings specifying short-form or option-value aliases -
help
(String
) The help string, which may benil
-
extras
An application-defined additional parameter. Ifnil
, it is assigned an emptyHash
-
-
Block An optional block that is called when a matching flag argument is found
NOTE: Users should prefer the +CLASP::Flag()+ method
# File lib/clasp/specifications.rb, line 108 def initialize(name, aliases, help, extras = nil, &blk) check_arity_(blk, 0..3, "flag") @name = name @aliases = (aliases || []).select { |a| a and not a.empty? } @help = help @extras = extras || {} @action = blk end
Public Instance Methods
Compares instance against another FlagSpecification
or against a name (String)
# File lib/clasp/specifications.rb, line 166 def == rhs case rhs when self.class return self.eql? rhs when String return name == rhs else false end end
String form of the flag
# File lib/clasp/specifications.rb, line 140 def to_s "{#{name}; aliases=#{aliases.join(', ')}; help='#{help}'; extras=#{extras}}" end