Class: Options
- Inherits:
-
Object
- Object
- Options
- Defined in:
- lib/freshmind.rb
Instance Attribute Summary collapse
-
#argv ⇒ Object
readonly
Returns the value of attribute argv.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
- #args ⇒ Object
-
#initialize(argv, options = {}) ⇒ Options
constructor
A new instance of Options.
Constructor Details
#initialize(argv, options = {}) ⇒ Options
Returns a new instance of Options.
22 23 24 25 |
# File 'lib/freshmind.rb', line 22 def initialize( argv, ={}) @argv = argv = end |
Instance Attribute Details
#argv ⇒ Object (readonly)
Returns the value of attribute argv.
21 22 23 |
# File 'lib/freshmind.rb', line 21 def argv @argv end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
21 22 23 |
# File 'lib/freshmind.rb', line 21 def end |
Instance Method Details
#args ⇒ Object
27 28 29 30 31 32 33 34 35 36 |
# File 'lib/freshmind.rb', line 27 def args res = {} .each do |opt_key, opt_value| opt_value[:variants].each do |variant| arg_index = argv.index(variant.to_s) res[opt_key] = arg_index.nil? ? opt_value[:default] : argv[arg_index].to_sym end end res end |