Method: GetoptLong#initialize
- Defined in:
- lib/getoptlong.rb
#initialize(*arguments) ⇒ GetoptLong
Set up option processing.
The options to support are passed to new() as an array of arrays. Each sub-array contains any number of String option names which carry the same meaning, and one of the following flags:
- GetoptLong::NO_ARGUMENT
-
Option does not take an argument.
- GetoptLong::REQUIRED_ARGUMENT
-
Option always takes an argument.
- GetoptLong::OPTIONAL_ARGUMENT
-
Option may or may not take an argument.
The first option name is considered to be the preferred (canonical) name. Other than that, the elements of each sub-array can be in any order.
128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 |
# File 'lib/getoptlong.rb', line 128 def initialize(*arguments) # # Current ordering. # if ENV.include?('POSIXLY_CORRECT') @ordering = REQUIRE_ORDER else @ordering = PERMUTE end # # Hash table of option names. # Keys of the table are option names, and their values are canonical # names of the options. # @canonical_names = Hash.new # # Hash table of argument flags. # Keys of the table are option names, and their values are argument # flags of the options. # @argument_flags = Hash.new # # Whether error messages are output to $stderr. # @quiet = FALSE # # Status code. # @status = STATUS_YET # # Error code. # @error = nil # # Error message. # @error_message = nil # # Rest of catenated short options. # @rest_singles = '' # # List of non-option-arguments. # Append them to ARGV when option processing is terminated. # @non_option_arguments = Array.new if 0 < arguments.length (*arguments) end end |