class Cl::Opt::Validator
Constants
- LONG
- MSGS
- SHORT
Public Instance Methods
apply()
click to toggle source
# File lib/cl/opt.rb, line 243 def apply error :missing_strs if strs.empty? error :wrong_strs if short.size > 1 || long.size > 1 error :invalid_strs, invalid unless invalid.empty? error :unknown_opts, unknown.map(&:inspect).join(', ') unless unknown.empty? [short.first, long.first] end
error(key, *args)
click to toggle source
# File lib/cl/opt.rb, line 271 def error(key, *args) raise Cl::Error, MSGS[key] % args end
invalid()
click to toggle source
# File lib/cl/opt.rb, line 255 def invalid @invalid ||= strs.-(valid).join(', ') end
long()
click to toggle source
# File lib/cl/opt.rb, line 267 def long strs.grep(LONG) end
short()
click to toggle source
# File lib/cl/opt.rb, line 263 def short strs.grep(SHORT) end
unknown()
click to toggle source
# File lib/cl/opt.rb, line 251 def unknown @unknown ||= opts.keys - Opt::OPTS end
valid()
click to toggle source
# File lib/cl/opt.rb, line 259 def valid strs.grep(Regexp.union(SHORT, LONG)) end