Class: Pakyow::Support::Aargv
- Inherits:
-
Object
- Object
- Pakyow::Support::Aargv
- Defined in:
- lib/pakyow/support/aargv.rb
Class Method Summary collapse
Class Method Details
.normalize(args, opts) ⇒ Object
10 11 12 13 14 |
# File 'lib/pakyow/support/aargv.rb', line 10 def self.normalize(args, opts) Hash[opts.map { |opt_name, opt_types| [opt_name, value_of_type(args, Array.ensure(opt_types))] }.reject { |pair| pair[1].nil? }] end |
.value_of_type(values, types) ⇒ Object
16 17 18 19 20 21 22 |
# File 'lib/pakyow/support/aargv.rb', line 16 def self.value_of_type(values, types) if match = values.find { |value| types.find { |type| value.is_a?(type) } } values.delete(match) else nil end end |