Sha256: c2d2ba32d2b6c0aa3cfdc2c70191091678010412d247e29b5acefcf06f4ed8a3

Contents?: true

Size: 497 Bytes

Versions: 1

Compression:

Stored size: 497 Bytes

Contents

module GetArgs
  class ArgumentList
    def initialize(args_array)
      @arguments = args_array.map { |arg| Argument.new(arg) }
    end
  
    def method_missing(*args)
      @arguments.send(*args)
    end
  end

  class Argument
    attr_reader :name, :default
  
    def initialize(arg_array)
      @optional = arg_array.length > 1
      @name, @default = *arg_array
    end
  
    def optional?
      @optional
    end
    
    def multiple?
      name.to_s.slice(0,1) == '*'
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
get_args-1.1.0 lib/argument_list.rb