Class: DMenu::Helper

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

Class Method Summary collapse

Class Method Details

.getopts(args, *opts) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/dmenu.rb', line 7

def self.getopts(args, *opts)
  values = []
  ret = []
  hash = args.inject({}) do |hash, arg|
    if Hash === arg
      hash.merge!(arg)
    end
    hash
  end
  args.each {|arg| values.push arg unless Hash === arg}
  opts.each do |opt|
    if hash[opt]
      ret.push hash[opt]
    else
      ret.push nil
    end
  end
  ret.push values
end