Method: CommandoVar#initialize

Defined in:
lib/scriptroute/commando.rb

#initialize(tags, description, varname, default = nil) ⇒ CommandoVar

Returns a new instance of CommandoVar.

Parameters:

  • tags (Array<String>, String)

    the options to recognize, either just a string "--option" or an array [ "-o", "--option" ]

  • description (String)

    help text to describe this option.

  • varname (Symbol)

    a global symbol to set to the value, e.g., ":$Option"

  • default (Object) (defaults to: nil)

    a default value for the option, if not set, useful for the help description. If the default is not a string, the assignment evals the variable unquoted. (That is, integer arguments should work as numbers without a need to convert.)



95
96
97
98
99
100
101
# File 'lib/scriptroute/commando.rb', line 95

def initialize(tags, description, varname, default=nil) 
  # should probably ensure that this isn't running setuid.
  super(tags, description)
  @varname = varname
  @default = default
  set(@default)
end