Module: NanDoc::OptsNormalizer

Included in:
CliCommandHelpers, CreateNanDocSite, Exclusive, OptEnum
Defined in:
lib/nandoc/support-modules.rb

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.



35
36
37
# File 'lib/nandoc/support-modules.rb', line 35

def exclusive_opt_flags opts, &block
  Exclusive.new(&block).parse(self, opts)
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[k.to_s.gsub('-','_').to_sym] = opts.delete(k)
  end
  opts
end

#unnormalize_opt_key(key) ⇒ Object



26
27
28
# File 'lib/nandoc/support-modules.rb', line 26

def unnormalize_opt_key key
  "--#{key.to_s.gsub('_','-')}"
end

#unnormalize_opt_keys(keys) ⇒ Object



23
24
25
# File 'lib/nandoc/support-modules.rb', line 23

def unnormalize_opt_keys keys
  keys.map{|x| unnormalize_opt_key(x)}
end