Class: Sawarineko::Option

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

Overview

Handle command line options.

Instance Method Summary collapse

Constructor Details

#initializeOption

Initialize a Option.



9
10
11
# File 'lib/sawarineko/option.rb', line 9

def initialize
  @options = {}
end

Instance Method Details

#parse(args) ⇒ Object

Parse the passed arguments to a Hash.

args - An Array of Strings containing options.

Returns an Array contains of a Hash options and an Array of Strings

remaining arguments.


19
20
21
22
23
24
25
26
# File 'lib/sawarineko/option.rb', line 19

def parse(args)
  OptionParser.new do |opts|
    opts.banner = 'Usage: sawarineko [options] [source]'

    add_options(opts)
  end.parse!(args)
  [@options, args]
end