summaryrefslogtreecommitdiff
path: root/doc/optparse/ruby
diff options
context:
space:
mode:
Diffstat (limited to 'doc/optparse/ruby')
-rw-r--r--doc/optparse/ruby/argument_abbreviation.rb9
-rw-r--r--doc/optparse/ruby/matched_values.rb6
2 files changed, 15 insertions, 0 deletions
diff --git a/doc/optparse/ruby/argument_abbreviation.rb b/doc/optparse/ruby/argument_abbreviation.rb
new file mode 100644
index 0000000000..49007ebe69
--- /dev/null
+++ b/doc/optparse/ruby/argument_abbreviation.rb
@@ -0,0 +1,9 @@
+require 'optparse'
+parser = OptionParser.new
+parser.on('-x', '--xxx=VALUE', %w[ABC def], 'Argument abbreviations') do |value|
+ p ['--xxx', value]
+end
+parser.on('-y', '--yyy=VALUE', {"abc"=>"XYZ", def: "FOO"}, 'Argument abbreviations') do |value|
+ p ['--yyy', value]
+end
+parser.parse!
diff --git a/doc/optparse/ruby/matched_values.rb b/doc/optparse/ruby/matched_values.rb
index f184ca8474..a1aba140e6 100644
--- a/doc/optparse/ruby/matched_values.rb
+++ b/doc/optparse/ruby/matched_values.rb
@@ -3,4 +3,10 @@ parser = OptionParser.new
parser.on('--xxx XXX', /foo/i, 'Matched values') do |value|
p ['--xxx', value]
end
+parser.on('--yyy YYY', Integer, 'Check by range', 1..3) do |value|
+ p ['--yyy', value]
+end
+parser.on('--zzz ZZZ', Integer, 'Check by list', [1, 3, 4]) do |value|
+ p ['--zzz', value]
+end
parser.parse!
td>ruby_1_9_1* 2011-08-25svn15 years ruby_1_8_6* 2010-09-02svn16 years ruby_1_8_5merge revision(s) 17483:shyouhei18 years ruby_1_3set svn:eol-styleshyouhei19 years ruby_1_4set svn:eol-styleshyouhei19 years ruby_1_6set svn:eol-styleshyouhei19 years v1_0rset svn:eol-styleshyouhei19 years v1_1devset svn:eol-styleshyouhei19 years v1_1rset svn:eol-styleshyouhei19 years  TagDownloadAuthorAge v4.0.4commit b89eb1bcbf...Takashi Kokubun4 weeks v4.0.3commit 85ddef263a...Takashi Kokubun7 weeks v3_2_11commit 5483bfc1ae...Hiroshi SHIBATA2 months v3_3_11commit 1f2d15125a...Hiroshi SHIBATA2 months v4.0.2commit d3da9fec82...Takashi Kokubun3 months v3_4_9commit 76cca827ab...nagachika3 months v3_2_10commit a3a6d25788...Hiroshi SHIBATA5 months v4.0.1commit e04267a14b...Takashi Kokubun5 months v4.0.0commit 553f1675f3...NARUSE, Yui5 months v4.0.0-preview3commit cfa3e7cf75...Augustin Gottlieb6 months v3_4_8commit 995b59f666...Takashi Kokubun6 months v4.0.0-preview2commit 4fa6e9938c...NARUSE, Yui7 months v3_3_10commit 343ea05002...nagachika7 months v3_4_7commit 7a5688e2a2...Takashi Kokubun8 months v3_4_6commit dbd83256b1...Takashi Kokubun9 months v3_3_9commit f5c772fc7c...nagachika10 months v3_2_9commit 8f611e0c46...Hiroshi SHIBATA10 months v3_4_5commit 20cda200d3...Takashi Kokubun11 months v3_4_4