Class: PoolParty::Optioner

Inherits:
Object show all
Defined in:
lib/poolparty/optioner.rb

Class Method Summary collapse

Class Method Details

.parse(argv, safe = []) ⇒ Object

Parse the command line options for options without a switch



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/poolparty/optioner.rb', line 4

def self.parse(argv, safe=[])
  args = []
  # Default options
  safe.push "-v"
  safe.push "-i"
  
  argv.each_with_index do |arg,i|
    unless arg.index("-") == 0# && !arg.match(/(?:[^"']+)/)
      args << arg
    else          
      argv.shift unless safe.include?(arg)
    end
  end
  args
end