Method: Clive::Option#initialize
- Defined in:
- lib/clive/option.rb
#initialize(names = [], description = "", config = {}, &block) ⇒ Option
Returns a new instance of Option.
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 |
# File 'lib/clive/option.rb', line 87 def initialize(names=[], description="", config={}, &block) @names = names.sort_by {|i| i.to_s.size } # @return [Symbol, nil] Short name from the names (ie. +:a+) def @names.short find {|i| i.to_s.size == 1 } end # @return [Symbol, nil] Long name from the names (ie. +:abc+) def @names.long find {|i| i.to_s.size > 1 } end @description = description @block = block @args = Arguments.create( get_subhash(config, Arguments::Parser::KEYS.keys) ) @config = DEFAULTS.merge( get_subhash(config, DEFAULTS.keys) || {} ) end |