Class: RipperTags::ForgivingOptionParser

Inherits:
OptionParser
  • Object
show all
Defined in:
lib/ripper-tags.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#ignore_unsupported_optionsObject

Returns the value of attribute ignore_unsupported_options.



36
37
38
# File 'lib/ripper-tags.rb', line 36

def ignore_unsupported_options
  @ignore_unsupported_options
end

Instance Method Details

#parse(argv) ⇒ Object



38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/ripper-tags.rb', line 38

def parse(argv)
  argv = argv.dup
  exceptions = []
  remaining = []

  while argv.size > 0
    begin
      remaining = super(argv)
      break
    rescue OptionParser::InvalidOption => err
      argv -= err.args
      exceptions << err
    end
  end

  if exceptions.any? && !ignore_unsupported_options
    raise exceptions.first
  end

  remaining
end