Class: MSPRelease::Options
- Inherits:
-
Object
- Object
- MSPRelease::Options
- Defined in:
- lib/msp_release/options.rb
Class Method Summary collapse
Instance Method Summary collapse
- #[](key) ⇒ Object
- #[]=(key, value) ⇒ Object
-
#initialize(args) ⇒ Options
constructor
A new instance of Options.
- #verbose? ⇒ Boolean
Constructor Details
#initialize(args) ⇒ Options
Returns a new instance of Options.
11 12 13 14 15 16 17 18 19 20 |
# File 'lib/msp_release/options.rb', line 11 def initialize(args) @store = { :verbose => false } opts = OptionParser.new do |opts| opts.on("-v", "--[no-]verbose", "Run with verbose output") do |v| @store[:verbose] = v end end.parse!(args) end |
Class Method Details
.get(given_args) ⇒ Object
5 6 7 8 9 |
# File 'lib/msp_release/options.rb', line 5 def self.get(given_args) args = given_args.clone opt = new(args) [opt, args] end |
Instance Method Details
#[](key) ⇒ Object
22 23 24 |
# File 'lib/msp_release/options.rb', line 22 def [](key) @store.fetch(key) end |
#[]=(key, value) ⇒ Object
26 27 28 29 |
# File 'lib/msp_release/options.rb', line 26 def []=(key, value) $stderr.puts("Warning, overiding config key #{key}") if @store[key] @store[key] = value end |
#verbose? ⇒ Boolean
31 32 33 |
# File 'lib/msp_release/options.rb', line 31 def verbose? self[:verbose] end |