Class: Bini::OptionParser
- Inherits:
-
OptionParser
- Object
- OptionParser
- Bini::OptionParser
- Defined in:
- lib/bini/optparser.rb
Instance Method Summary collapse
- #[](k = nil) ⇒ Object
- #[]=(k, v) ⇒ Object
-
#clear ⇒ Object
These are the hash like bits.
-
#initialize ⇒ OptionParser
constructor
A new instance of OptionParser.
-
#mash(h) ⇒ Object
merge takes in a set of values and overwrites the previous values.
- #parse! ⇒ Object
Constructor Details
#initialize ⇒ OptionParser
Returns a new instance of OptionParser.
5 6 7 8 9 10 |
# File 'lib/bini/optparser.rb', line 5 def initialize super @options = {} on("-V", "--version", "Print version") { |version| @options[:version] = true} end |
Instance Method Details
#[](k = nil) ⇒ Object
33 34 35 36 37 |
# File 'lib/bini/optparser.rb', line 33 def [](k = nil) return @options[k] if k return @options if @options.any? {} end |
#[]=(k, v) ⇒ Object
39 40 41 |
# File 'lib/bini/optparser.rb', line 39 def []=(k,v) @options[k] = v end |
#clear ⇒ Object
These are the hash like bits.
29 30 31 |
# File 'lib/bini/optparser.rb', line 29 def clear @options.clear end |
#mash(h) ⇒ Object
merge takes in a set of values and overwrites the previous values. mash does this in reverse.
45 46 47 48 49 |
# File 'lib/bini/optparser.rb', line 45 def mash(h) h.merge! @options @options.clear h.each {|k,v| self[k] = v} end |