mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
[ruby/optparse] Reorganize Ruby example files for sharing (#14)
9a2352c1c9
This commit is contained in:
parent
97abd0f6af
commit
c795f30ef0
45 changed files with 43 additions and 55 deletions
11
doc/ruby/method.rb
Normal file
11
doc/ruby/method.rb
Normal file
|
@ -0,0 +1,11 @@
|
|||
require 'optparse'
|
||||
parser = OptionParser.new
|
||||
def xxx_handler(value)
|
||||
p ['Handler method for -xxx called with value:', value]
|
||||
end
|
||||
parser.on('--xxx', 'Option with no argument', method(:xxx_handler))
|
||||
def yyy_handler(value)
|
||||
p ['Handler method for -yyy called with value:', value]
|
||||
end
|
||||
parser.on('--yyy YYY', 'Option with required argument', method(:yyy_handler))
|
||||
parser.parse!
|
Loading…
Add table
Add a link
Reference in a new issue