End of Life Ruby 3.2 has reached end of life and gets no more fixes. Switch to Ruby 4.0 →
instance method
GetoptLong#ordering=
ordering=(ordering)
lib/getoptlong.rb
View on GitHub ↗
# File tmp/rubies/ruby-3.2.0/lib/getoptlong.rb, line 489
def ordering=(ordering)
#
# The method is failed if option processing has already started.
#
if @status != STATUS_YET
set_error(ArgumentError, "argument error")
raise RuntimeError,
"invoke ordering=, but option processing has already started"
end
#
# Check ordering.
#
if !ORDERINGS.include?(ordering)
raise ArgumentError, "invalid ordering `#{ordering}'"
end
if ordering == PERMUTE && ENV.include?('POSIXLY_CORRECT')
@ordering = REQUIRE_ORDER
else
@ordering = ordering
end
end
Sets the ordering; see Ordering; returns the new ordering.
If the given ordering is PERMUTE and environment variable POSIXLY_CORRECT is defined, sets the ordering to REQUIRE_ORDER; otherwise sets the ordering to ordering:
Example
options = GetoptLong.new options.ordering == GetoptLong::PERMUTE # => true options.ordering = GetoptLong::RETURN_IN_ORDER options.ordering == GetoptLong::RETURN_IN_ORDER # => true ENV['POSIXLY_CORRECT'] = 'true' options.ordering = GetoptLong::PERMUTE options.ordering == GetoptLong::REQUIRE_ORDER # => true
Raises an exception if ordering is invalid.