Class: Sawarineko::Option
- Inherits:
-
Object
- Object
- Sawarineko::Option
- Defined in:
- lib/sawarineko/option.rb
Overview
Handle command line options.
Instance Method Summary collapse
-
#initialize ⇒ Option
constructor
Initialize a Option.
-
#parse(args) ⇒ Object
Parse the passed arguments to a Hash.
Constructor Details
#initialize ⇒ Option
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. = 'Usage: sawarineko [options] [source]' (opts) end.parse!(args) [@options, args] end |