Skip to content

Commit

Permalink
Reorganize Ruby example files for sharing (#14)
Browse files Browse the repository at this point in the history
  • Loading branch information
BurdetteLamar authored Apr 9, 2021
1 parent f3ca83c commit 9a2352c
Show file tree
Hide file tree
Showing 45 changed files with 43 additions and 55 deletions.
4 changes: 2 additions & 2 deletions doc/creates_option.rdoc
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Creates an option from the given parameters +params+.
See {Parameters for New Options}[doc/option_params/option_params_rdoc.html].
See {Parameters for New Options}[doc/option_params_rdoc.html].

The block, if given, is the handler for the created option.
When the option is encountered during command-line parsing,
the block is called with the argument given for the option, if any.
See {Option Handlers}[doc/option_params/option_params_rdoc.html#label-Option+Handlers].
See {Option Handlers}[doc/option_params_rdoc.html#label-Option+Handlers].
70 changes: 35 additions & 35 deletions doc/option_params/option_params.rdoc → doc/option_params.rdoc
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ File +short_simple.rb+ defines two options:
- One with short name <tt>-x</tt>.
- The other with two short names, in effect, aliases, <tt>-1</tt> and <tt>-%</tt>.

:include: short_simple.rb
:include: ruby/short_simple.rb

Executions:

Expand All @@ -100,7 +100,7 @@ defines an option that requires an argument.
File +short_required.rb+ defines an option <tt>-x</tt>
that requires an argument.

:include: short_required.rb
:include: ruby/short_required.rb

Executions:

Expand All @@ -120,7 +120,7 @@ defines an option that allows an optional argument.
File +short_optional.rb+ defines an option <tt>-x</tt>
that allows an optional argument.

:include: short_optional.rb
:include: ruby/short_optional.rb

Executions:

Expand All @@ -141,7 +141,7 @@ The parser yields both the actual character cited and the value.
File +short_range.rb+ defines an option with short names
for all printable characters from <tt>!</tt> to <tt>~</tt>:

:include: short_range.rb
:include: ruby/short_range.rb

Executions:

Expand All @@ -167,7 +167,7 @@ File +long_simple.rb+ defines two options:
- The other with two long names, in effect, aliases,
<tt>--y1%</tt> and <tt>--z2#</tt>.

:include: long_simple.rb
:include: ruby/long_simple.rb

Executions:

Expand All @@ -190,7 +190,7 @@ defines an option that requires an argument.
File +long_required.rb+ defines an option <tt>--xxx</tt>
that requires an argument.

:include: long_required.rb
:include: ruby/long_required.rb

Executions:

Expand All @@ -210,7 +210,7 @@ defines an option that allows an optional argument.
File +long_optional.rb+ defines an option <tt>--xxx</tt>
that allows an optional argument.

:include: long_optional.rb
:include: ruby/long_optional.rb

Executions:

Expand All @@ -228,7 +228,7 @@ An option may have both short and long names.

File +mixed_names.rb+ defines a mixture of short and long names.

:include: mixed_names.rb
:include: ruby/mixed_names.rb

Executions:

Expand Down Expand Up @@ -272,7 +272,7 @@ which is one of <tt>:NONE</tt> (the default),

File +argument_keywords.rb+ defines an option with a required argument.

:include: argument_keywords.rb
:include: ruby/argument_keywords.rb

Executions:

Expand All @@ -291,7 +291,7 @@ is to define it in a string separate from the name string.

File +argument_strings.rb+ defines an option with a required argument.

:include: argument_strings.rb
:include: ruby/argument_strings.rb

Executions:

Expand Down Expand Up @@ -323,7 +323,7 @@ The argument value must be one of those strings.

File +explicit_array_values.rb+ defines options with explicit argument values.

:include: explicit_array_values.rb
:include: ruby/explicit_array_values.rb

Executions:

Expand All @@ -349,7 +349,7 @@ and the value yielded will be the value for that key.

File +explicit_hash_values.rb+ defines options with explicit argument values.

:include: explicit_hash_values.rb
:include: ruby/explicit_hash_values.rb

Executions:

Expand Down Expand Up @@ -381,7 +381,7 @@ by specifying a Regexp that the given argument must match.

File +matched_values.rb+ defines options with matched argument values.

:include: matched_values.rb
:include: ruby/matched_values.rb

Executions:

Expand Down Expand Up @@ -410,7 +410,7 @@ defines an option whose argument is to be converted to a \Date object.
The argument is converted by method
{Date.parse}[https://ruby-doc.org/stdlib/libdoc/date/rdoc/Date.html#method-c-parse].

:include: date.rb
:include: ruby/date.rb

Executions:

Expand All @@ -428,7 +428,7 @@ defines an option whose argument is to be converted to a \DateTime object.
The argument is converted by method
{DateTime.parse}[https://ruby-doc.org/stdlib-2.6.1/libdoc/date/rdoc/DateTime.html#method-c-parse].

:include: datetime.rb
:include: ruby/datetime.rb

Executions:

Expand All @@ -447,7 +447,7 @@ The argument is converted by method
{Time.httpdate}[https://ruby-doc.org/stdlib-2.7.0/libdoc/time/rdoc/Time.html#method-c-httpdate] or
{Time.parse}[https://ruby-doc.org/stdlib-2.7.0/libdoc/time/rdoc/Time.html#method-c-parse].

:include: time.rb
:include: ruby/time.rb

Executions:

Expand All @@ -463,7 +463,7 @@ defines an option whose argument is to be converted to a \URI object.
The argument is converted by method
{URI.parse}[https://ruby-doc.org/stdlib-2.7.2/libdoc/uri/rdoc/URI.html#method-c-parse].

:include: uri.rb
:include: ruby/uri.rb

Executions:

Expand All @@ -480,7 +480,7 @@ File +shellwords.rb+
defines an option whose argument is to be converted to an \Array object by method
{Shellwords.shellwords}[https://ruby-doc.org/stdlib-2.7.0/libdoc/shellwords/rdoc/Shellwords.html#method-c-shellwords].

:include: shellwords.rb
:include: ruby/shellwords.rb

Executions:

Expand All @@ -496,7 +496,7 @@ defines an option whose argument is to be converted to an \Integer object.
The argument is converted by method
{Kernel.Integer}[https://ruby-doc.org/core/Kernel.html#method-i-Integer].

:include: integer.rb
:include: ruby/integer.rb

Executions:

Expand All @@ -518,7 +518,7 @@ defines an option whose argument is to be converted to a \Float object.
The argument is converted by method
{Kernel.Float}[https://ruby-doc.org/core/Kernel.html#method-i-Float].

:include: float.rb
:include: ruby/float.rb

Executions:

Expand All @@ -541,7 +541,7 @@ The argument is converted by method
{Kernel.Float}[https://ruby-doc.org/core/Kernel.html#method-i-Float], or
{Kernel.Integer}[https://ruby-doc.org/core/Kernel.html#method-i-Integer].

:include: numeric.rb
:include: ruby/numeric.rb

Executions:

Expand All @@ -559,7 +559,7 @@ defines an option whose argument is to be converted to an \Integer object.
The argument is converted by method
{Kernel.Integer}[https://ruby-doc.org/core/Kernel.html#method-i-Integer].

:include: decimal_integer.rb
:include: ruby/decimal_integer.rb

The argument may not be in a binary or hexadecimal format;
a leading zero is ignored (not parsed as octal).
Expand All @@ -582,7 +582,7 @@ defines an option whose argument is to be converted to an \Integer object.
The argument is converted by method
{Kernel.Integer}[https://ruby-doc.org/core/Kernel.html#method-i-Integer].

:include: octal_integer.rb
:include: ruby/octal_integer.rb

The argument may not be in a binary or hexadecimal format;
it is parsed as octal, regardless of whether it has a leading zero.
Expand All @@ -603,7 +603,7 @@ defines an option whose argument is to be converted to an \Integer object.
The argument is converted by method
{Kernel.Integer}[https://ruby-doc.org/core/Kernel.html#method-i-Integer].

:include: decimal_numeric.rb
:include: ruby/decimal_numeric.rb

The argument may not be in a binary or hexadecimal format;
a leading zero causes the argument to be parsed as octal.
Expand All @@ -624,7 +624,7 @@ defines an option whose argument is to be converted to +true+ or +false+.
The argument is evaluated by method
{Object#nil?}[https://ruby-doc.org/core-3.0.0/Object.html#method-i-nil-3F].

:include: true_class.rb
:include: ruby/true_class.rb

The argument may be any of those shown in the examples below.

Expand Down Expand Up @@ -652,7 +652,7 @@ defines an option whose argument is to be converted to +true+ or +false+.
The argument is evaluated by method
{Object#nil?}[https://ruby-doc.org/core-3.0.0/Object.html#method-i-nil-3F].

:include: false_class.rb
:include: ruby/false_class.rb

The argument may be any of those shown in the examples below.

Expand All @@ -678,7 +678,7 @@ Executions:
File +object.rb+
defines an option whose argument is not to be converted from \String.

:include: object.rb
:include: ruby/object.rb

Executions:

Expand All @@ -692,7 +692,7 @@ Executions:
File +string.rb+
defines an option whose argument is not to be converted from \String.

:include: string.rb
:include: ruby/string.rb

Executions:

Expand All @@ -707,7 +707,7 @@ File +array.rb+
defines an option whose argument is to be converted from \String
to an array of strings, based on comma-separated substrings.

:include: array.rb
:include: ruby/array.rb

Executions:

Expand All @@ -723,7 +723,7 @@ Executions:
File +regexp.rb+
defines an option whose argument is to be converted to a \Regexp object.

:include: regexp.rb
:include: ruby/regexp.rb

Executions:

Expand All @@ -744,7 +744,7 @@ File +descriptions.rb+ has six strings in its array +descriptions+.
These are all passed as parameters to OptionParser#on, so that they
all, line for line, become the option's description.

:include: descriptions.rb
:include: ruby/descriptions.rb

Executions:

Expand Down Expand Up @@ -774,7 +774,7 @@ An option hadler may be a block.

File +block.rb+ defines an option that has a handler block.

:include: block.rb
:include: ruby/block.rb

Executions:

Expand All @@ -793,7 +793,7 @@ An option handler may be a Proc.

File +proc.rb+ defines an option that has a handler proc.

:include: proc.rb
:include: ruby/proc.rb

Executions:

Expand All @@ -812,7 +812,7 @@ An option handler may be a Method.

File +proc.rb+ defines an option that has a handler method.

:include: method.rb
:include: ruby/method.rb

Executions:

Expand All @@ -833,7 +833,7 @@ This can be useful if there are options not meant for the current program.

File +terminator.rb+ defines one option <tt>--my_option</tt>.

:include: terminator.rb
:include: ruby/terminator.rb

The first execution fails because <tt>--nosuch</tt> is not a defined option;
the second succeeds because <tt>--</tt> causes that option to be ignored:
Expand Down
12 changes: 0 additions & 12 deletions doc/option_params/mixed_names.rb

This file was deleted.

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
12 changes: 6 additions & 6 deletions doc/tutorial/tutorial.rdoc → doc/tutorial.rdoc
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ When a Ruby program executes, it captures its command-line arguments
and options into variable ARGV.
This simple program just prints its \ARGV:

:include: argv.rb
:include: ruby/argv.rb

Execution, with arguments and options:

Expand Down Expand Up @@ -67,7 +67,7 @@ File +short_names.rb+
defines an option with a short name, <tt>-x</tt>,
and an option with two short names (aliases, in effect) <tt>-y</tt> and <tt>-z</tt>.

:include: short_names.rb
:include: ruby/short_names.rb

Executions:

Expand Down Expand Up @@ -99,7 +99,7 @@ File +long_names.rb+
defines an option with a long name, <tt>--xxx</tt>,
and an option with two long names (aliases, in effect) <tt>--y1%</tt> and <tt>--z2#</tt>.

:include: long_names.rb
:include: ruby/long_names.rb

Executions:

Expand All @@ -118,7 +118,7 @@ so that a short name is in effect an abbreviation of a long name.
File +mixed_names.rb+
defines options that each have both a short and a long name.

:include: mixed_names.rb
:include: ruby/mixed_names.rb

Executions:

Expand Down Expand Up @@ -147,7 +147,7 @@ to its name definition.
File +required_argument.rb+ defines two options;
each has a required argument because the name definition has a following dummy word.

:include: required_argument.rb
:include: ruby/required_argument.rb

When an option is found, the given argument is yielded.

Expand All @@ -172,7 +172,7 @@ File +optional_argument.rb+ defines two options;
each has an optional argument because the name definition has a following dummy word
in square brackets.

:include: optional_argument.rb
:include: ruby/optional_argument.rb

When an option with an argument is found, the given argument yielded.

Expand Down

0 comments on commit 9a2352c

Please sign in to comment.