class OptimistXL::LongNames
Public Class Methods
new()
click to toggle source
# File lib/optimist_xl.rb, line 792 def initialize @truename = nil @long = nil @alts = [] end
Public Instance Methods
long()
click to toggle source
long specified with :long has precedence over the true-name
# File lib/optimist_xl.rb, line 816 def long ; @long || @truename ; end
make_valid(lopt)
click to toggle source
# File lib/optimist_xl.rb, line 798 def make_valid(lopt) return nil if lopt.nil? case lopt.to_s when /^--([^-].*)$/ then $1 when /^[^-]/ then lopt.to_s else raise ArgumentError, "invalid long option name #{lopt.inspect}" end end
names()
click to toggle source
all valid names, including alts
# File lib/optimist_xl.rb, line 819 def names [long] + @alts end
set(name, lopt, alts)
click to toggle source
# File lib/optimist_xl.rb, line 807 def set(name, lopt, alts) @truename = name lopt = lopt ? lopt.to_s : name.to_s.gsub("_", "-") @long = make_valid(lopt) alts = [alts] unless alts.is_a?(Array) # box the value @alts = alts.map { |alt| make_valid(alt) }.compact end