Class: Racli::OptionParser

Inherits:
Object
  • Object
show all
Defined in:
lib/racli/option_parser.rb

Instance Method Summary collapse

Instance Method Details

#call(args) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/racli/option_parser.rb', line 7

def call(args)
  options, args = parse(args)
  config_params = { config: options[:config], rcfile: options[:rcfile] }

  params = { method: 'GET', path: '/' }
  params[:method] = args[0] unless args.empty?
  params[:path] = args[1] if args.length > 1

  request_params = options.dup
  request_params.delete(:config)
  request_params.delete(:rcfile)
  params[:params] = request_params

  [config_params, params]
end