Method: NanDoc::Cli::OptionMethods::OptionEnum#parse
- Defined in:
- lib/nandoc/cli/option-methods/option-enum.rb
#parse(opts) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/nandoc/cli/option-methods/option-enum.rb', line 22 def parse opts found = nil if opts.key?(@name) v = opts[@name] re = /\A#{Regexp.escape(v)}/ founds = @values.grep(re) case founds.size when 0; invalid(v) when 1; found = founds.first else found = founds.detect{|f| f==v} or too_many(founds) end elsif(@default) found = @default else found = nil end opts[@name] = found if found # normalize short versions found end |