Module: NanDoc::OptsNormalizer
Defined Under Namespace
Classes: Exclusive, OptEnum
Instance Method Summary
collapse
Instance Method Details
#exclusive_opt_flags(opts, &block) ⇒ Object
only call this if you are like a ::Cri::Command object with all the nanDoc hacks. ick. This is a temprary hack. Trollop et al do this better.
38
39
40
|
# File 'lib/nandoc/support-modules.rb', line 38
def exclusive_opt_flags opts, &block
Exclusive.new(&block).parse(self, opts)
end
|
#normalize_opt_key(k) ⇒ Object
23
24
25
|
# File 'lib/nandoc/support-modules.rb', line 23
def normalize_opt_key k
k.to_s.gsub('-','_').to_sym
end
|
#normalize_opts(opts) ⇒ Object
16
17
18
19
20
21
22
|
# File 'lib/nandoc/support-modules.rb', line 16
def normalize_opts opts
opts = opts.dup
opts.keys.select{|x| x.to_s.index('-') }.each do |k|
opts[normalize_opt_key(k)] = opts.delete(k)
end
opts
end
|
#unnormalize_opt_key(key) ⇒ Object
29
30
31
|
# File 'lib/nandoc/support-modules.rb', line 29
def unnormalize_opt_key key
"--#{key.to_s.gsub('_','-')}"
end
|
#unnormalize_opt_keys(keys) ⇒ Object
26
27
28
|
# File 'lib/nandoc/support-modules.rb', line 26
def unnormalize_opt_keys keys
keys.map{|x| unnormalize_opt_key(x)}
end
|