summaryrefslogtreecommitdiff
path: root/doc/ruby/method.rb
blob: 3f02ff57986a21a78d6f17e01425a4ca2c66ea6b (plain)
1
2
3
4
5
6
7
8
9
10
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!