module Toys::Completion
def self.create(spec = nil, **options, &block)
- 
        (Toys::Completion::Base, Proc)-
Parameters:
- 
        block(Proc) -- See the description for recognized forms.
- 
        options(Hash) -- Additional options to pass to the completion.
- 
        spec(Object) -- See the description for recognized values.
def self.create(spec = nil, **options, &block) if spec.is_a?(::Hash) options = options.merge(spec) spec = nil end spec ||= options.delete(:"") || block case spec when nil, :empty, :default EMPTY when ::Proc, Base spec when ::Array Enum.new(spec, **options) when :file_system FileSystem.new(**options) when ::Class spec.new(**options) else if spec.respond_to?(:call) spec else raise ToolDefinitionError, "Illegal completion spec: #{spec.inspect}" end end end
def self.scalarize_spec(spec, options, block)
def self.scalarize_spec(spec, options, block) spec ||= block if options.empty? spec elsif spec options.merge({"": spec}) else options end end