Class: OptParseSimple

Inherits:
Object
  • Object
show all
Extended by:
IndifferentVariableHash
Defined in:
lib/optparse-simple.rb,
lib/optparse-simple.rb

Overview

:nodoc:

Defined Under Namespace

Classes: Option

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(&block) ⇒ OptParseSimple

whether or not OptParseSimple acts like OptionParser



15
16
17
# File 'lib/optparse-simple.rb', line 15

def initialize &block
  block.call self
end

Instance Attribute Details

#optionsObject

:nodoc:



10
11
12
# File 'lib/optparse-simple.rb', line 10

def options
  @options
end

Instance Method Details

#on(*args, &block) ⇒ Object



34
35
36
# File 'lib/optparse-simple.rb', line 34

def on *args, &block
  options << Option.new(*args, &block)
end

#parse(args) ⇒ Object



19
20
21
22
# File 'lib/optparse-simple.rb', line 19

def parse args
  check_for_invalid_options(args) if OptParseSimple.compatibility_mode
  options.each {|option| option.parse(args) }
end

#parse!(args) ⇒ Object



24
25
26
27
# File 'lib/optparse-simple.rb', line 24

def parse! args
  check_for_invalid_options(args) if OptParseSimple.compatibility_mode
  options.each {|option| option.parse!(args) }
end