class Optimist::ShortNames
Attributes
auto[R]
chars[R]
Public Class Methods
new()
click to toggle source
# File lib/optimist.rb, line 731 def initialize @chars = [] @auto = true end
Public Instance Methods
add(values)
click to toggle source
# File lib/optimist.rb, line 738 def add(values) values = [values] unless values.is_a?(Array) # box the value values = values.compact if values.include?(:none) if values.size == 1 @auto = false return end raise ArgumentError, "Cannot use :none with any other values in short option: #{values.inspect}" end values.each do |val| strval = val.to_s sopt = case strval when /^-(.)$/ then $1 when /^.$/ then strval else raise ArgumentError, "invalid short option name '#{val.inspect}'" end if sopt =~ INVALID_ARG_REGEX raise ArgumentError, "short option name '#{sopt}' can't be a number or a dash" end @chars << sopt end end