Class: Optimus
- Inherits:
-
Object
- Object
- Optimus
- Defined in:
- lib/optimus/parser.rb,
lib/optimus/option.rb,
lib/optimus/optimus.rb,
lib/optimus/options.rb,
lib/optimus/version.rb,
lib/optimus/interface.rb,
lib/optimus/implementation.rb,
lib/optimus/implementations/advanced.rb,
lib/optimus/implementations/standard.rb
Overview
Copyright © 2010 tilde [tilde AT autistici DOT org]
meh [meh.ffff AT gmail DOT com]
This file is part of optimus.
optimus is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with optimus. If not, see <http://www.gnu.org/licenses/>.
Defined Under Namespace
Modules: Implementations, Parsers Classes: Implementation, Interface, Option, Options, Parser
Constant Summary collapse
- Version =
'0.0.2'
Instance Attribute Summary collapse
-
#implementation ⇒ Object
readonly
Returns the value of attribute implementation.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
-
#initialize(*args) ⇒ Optimus
constructor
Initialize Optimus with an array of options or ARGV.
- #method_missing(method, *args, &block) ⇒ Object
-
#parse(values, parserOptions = nil) ⇒ Object
Parse additional options and merge them to the Optimus object.
Constructor Details
#initialize(*args) ⇒ Optimus
Initialize Optimus with an array of options or ARGV
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/optimus/optimus.rb', line 25 def initialize (*args) if !block_given? = args.shift || [] end values = args.shift || ARGV implementation = args.shift || Implementations::Standard.new if block_given? yield @options = Options.new(implementation) @options.parse(values) else @options = Options.parse(, values, implementation) end @implementation = implementation end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &block) ⇒ Object
56 57 58 |
# File 'lib/optimus/optimus.rb', line 56 def method_missing (method, *args, &block) @options.send(method, *args, &block) end |
Instance Attribute Details
#implementation ⇒ Object (readonly)
Returns the value of attribute implementation.
22 23 24 |
# File 'lib/optimus/optimus.rb', line 22 def implementation @implementation end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
22 23 24 |
# File 'lib/optimus/optimus.rb', line 22 def @options end |
Instance Method Details
#parse(values, parserOptions = nil) ⇒ Object
Parse additional options and merge them to the Optimus object
44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/optimus/optimus.rb', line 44 def parse (values, parserOptions=nil) = Options.parse(@options., values, @implementation, parserOptions) if block_given? yield end @options.merge!() return end |