michelle1 0 Newbie Poster

Hi there,

QUESTION:
Whilst "parse(argv)" is obvious, what does "opts.parse!(argv)" do in the below code? And what is the word use to describe doing this?

CONTEXT:
I am looking at a class called 'Options' whose job is to parse command line options which get passed to a program called 'PartInspector'. An extract of this class follows:

class Options
    
  def initialize(argv)
    @directory = DEFAULT_DIR
    parse(argv)  
  end

  private
    def parse(argv)
      OptionParser.new do |opts|
      opts.banner = "Usage:  PartInspector [part_number]"

      opts.on("-h", "Shows this message") do
        puts opts
        exit
      end

      begin
        argv = ["-h"] if argv.empty?
        opts.parse!(argv)                          ## <------- HERE?!!?!
        rescue OptionParser::ParseError => e
          STDERR.puts e.message, "\n", opts
      end
    end#def parse()    
   end#private class

end#Options class

I know its probably some basic syntax for ruby, not knowing what it is called however makes it difficult to look it up.

Thanks in advance, Michelle