Sha256: 33051d763c99a8ffc0fac118fa875f0e1a7f64a371a183578ff63f6c6dba2769

Contents?: true

Size: 483 Bytes

Versions: 5

Compression:

Stored size: 483 Bytes

Contents

module Gnip
  module Arguments
    def options
      @options ||= Options.for(last.is_a?(Hash) ? pop : {})
    end

    %w[ getopt getopts hasopt hasopts delopt delopts ].each do |method|
      module_eval <<-code
        def #{ method }(*args, &block)
          options.#{ method }(*args, &block)
        end
      code
    end

    def Arguments.for(args)
      raise ArgumentError unless args.is_a?(Array)
      args.extend(Arguments)
      [args, args.options]
    end
  end
end

Version data entries

5 entries across 5 versions & 2 rubygems

Version Path
gnip-gnip-1.1.1 lib/gnip/arguments.rb
gnip-0.4.2 lib/gnip/arguments.rb
gnip-1.0.0 lib/gnip/arguments.rb
gnip-1.1.1 lib/gnip/arguments.rb
gnip-1.1.2 lib/gnip/arguments.rb