2004-01-20 00:04:31 -05:00
|
|
|
# Include the English library file in a Ruby script, and you can
|
|
|
|
# reference the global variables such as \VAR{\$\_} using less
|
|
|
|
# cryptic names, listed in the following table.% \vref{tab:english}.
|
|
|
|
#
|
|
|
|
# Without 'English':
|
|
|
|
#
|
|
|
|
# $\ = ' -- '
|
|
|
|
# "waterbuffalo" =~ /buff/
|
2014-05-31 15:54:55 -04:00
|
|
|
# print $', $$, "\n"
|
2004-01-20 00:04:31 -05:00
|
|
|
#
|
|
|
|
# With English:
|
|
|
|
#
|
|
|
|
# require "English"
|
2009-03-05 22:56:38 -05:00
|
|
|
#
|
2004-01-20 00:04:31 -05:00
|
|
|
# $OUTPUT_FIELD_SEPARATOR = ' -- '
|
|
|
|
# "waterbuffalo" =~ /buff/
|
2014-05-31 15:54:55 -04:00
|
|
|
# print $POSTMATCH, $PID, "\n"
|
2013-02-03 14:21:37 -05:00
|
|
|
#
|
|
|
|
# Below is a full list of descriptive aliases and their associated global
|
|
|
|
# variable:
|
|
|
|
#
|
|
|
|
# $ERROR_INFO:: $!
|
|
|
|
# $ERROR_POSITION:: $@
|
|
|
|
# $FS:: $;
|
|
|
|
# $FIELD_SEPARATOR:: $;
|
|
|
|
# $OFS:: $,
|
|
|
|
# $OUTPUT_FIELD_SEPARATOR:: $,
|
|
|
|
# $RS:: $/
|
|
|
|
# $INPUT_RECORD_SEPARATOR:: $/
|
|
|
|
# $ORS:: $\
|
|
|
|
# $OUTPUT_RECORD_SEPARATOR:: $\
|
|
|
|
# $INPUT_LINE_NUMBER:: $.
|
|
|
|
# $NR:: $.
|
|
|
|
# $LAST_READ_LINE:: $_
|
|
|
|
# $DEFAULT_OUTPUT:: $>
|
|
|
|
# $DEFAULT_INPUT:: $<
|
|
|
|
# $PID:: $$
|
|
|
|
# $PROCESS_ID:: $$
|
|
|
|
# $CHILD_STATUS:: $?
|
|
|
|
# $LAST_MATCH_INFO:: $~
|
|
|
|
# $IGNORECASE:: $=
|
|
|
|
# $ARGV:: $*
|
|
|
|
# $MATCH:: $&
|
|
|
|
# $PREMATCH:: $`
|
|
|
|
# $POSTMATCH:: $'
|
|
|
|
# $LAST_PAREN_MATCH:: $+
|
|
|
|
#
|
2013-02-03 21:50:20 -05:00
|
|
|
module English end if false
|
2004-01-20 00:04:31 -05:00
|
|
|
|
|
|
|
# The exception object passed to +raise+.
|
1998-01-16 07:13:05 -05:00
|
|
|
alias $ERROR_INFO $!
|
2004-01-20 00:04:31 -05:00
|
|
|
|
|
|
|
# The stack backtrace generated by the last
|
|
|
|
# exception. <tt>See Kernel.caller</tt> for details. Thread local.
|
1998-01-16 07:13:05 -05:00
|
|
|
alias $ERROR_POSITION $@
|
2004-01-20 00:04:31 -05:00
|
|
|
|
|
|
|
# The default separator pattern used by <tt>String.split</tt>. May be
|
|
|
|
# set from the command line using the <tt>-F</tt> flag.
|
1998-01-16 07:13:05 -05:00
|
|
|
alias $FS $;
|
2004-01-20 00:04:31 -05:00
|
|
|
|
|
|
|
# The default separator pattern used by <tt>String.split</tt>. May be
|
|
|
|
# set from the command line using the <tt>-F</tt> flag.
|
1998-01-16 07:13:05 -05:00
|
|
|
alias $FIELD_SEPARATOR $;
|
2004-01-20 00:04:31 -05:00
|
|
|
|
|
|
|
# The separator string output between the parameters to methods such
|
|
|
|
# as <tt>Kernel.print</tt> and <tt>Array.join</tt>. Defaults to +nil+,
|
|
|
|
# which adds no text.
|
1998-01-16 07:13:05 -05:00
|
|
|
alias $OFS $,
|
2004-01-20 00:04:31 -05:00
|
|
|
|
|
|
|
# The separator string output between the parameters to methods such
|
|
|
|
# as <tt>Kernel.print</tt> and <tt>Array.join</tt>. Defaults to +nil+,
|
|
|
|
# which adds no text.
|
1998-01-16 07:13:05 -05:00
|
|
|
alias $OUTPUT_FIELD_SEPARATOR $,
|
2004-01-20 00:04:31 -05:00
|
|
|
|
|
|
|
# The input record separator (newline by default). This is the value
|
|
|
|
# that routines such as <tt>Kernel.gets</tt> use to determine record
|
|
|
|
# boundaries. If set to +nil+, +gets+ will read the entire file.
|
1998-01-16 07:13:05 -05:00
|
|
|
alias $RS $/
|
2004-01-20 00:04:31 -05:00
|
|
|
|
|
|
|
# The input record separator (newline by default). This is the value
|
|
|
|
# that routines such as <tt>Kernel.gets</tt> use to determine record
|
|
|
|
# boundaries. If set to +nil+, +gets+ will read the entire file.
|
1998-01-16 07:13:05 -05:00
|
|
|
alias $INPUT_RECORD_SEPARATOR $/
|
2004-01-20 00:04:31 -05:00
|
|
|
|
|
|
|
# The string appended to the output of every call to methods such as
|
|
|
|
# <tt>Kernel.print</tt> and <tt>IO.write</tt>. The default value is
|
|
|
|
# +nil+.
|
1998-01-16 07:13:05 -05:00
|
|
|
alias $ORS $\
|
2004-01-20 00:04:31 -05:00
|
|
|
|
|
|
|
# The string appended to the output of every call to methods such as
|
|
|
|
# <tt>Kernel.print</tt> and <tt>IO.write</tt>. The default value is
|
|
|
|
# +nil+.
|
2002-01-11 04:22:04 -05:00
|
|
|
alias $OUTPUT_RECORD_SEPARATOR $\
|
2004-01-20 00:04:31 -05:00
|
|
|
|
|
|
|
# The number of the last line read from the current input file.
|
1998-01-16 07:13:05 -05:00
|
|
|
alias $INPUT_LINE_NUMBER $.
|
2004-01-20 00:04:31 -05:00
|
|
|
|
|
|
|
# The number of the last line read from the current input file.
|
1998-01-16 07:13:05 -05:00
|
|
|
alias $NR $.
|
2004-01-20 00:04:31 -05:00
|
|
|
|
|
|
|
# The last line read by <tt>Kernel.gets</tt> or
|
|
|
|
# <tt>Kernel.readline</tt>. Many string-related functions in the
|
|
|
|
# +Kernel+ module operate on <tt>$_</tt> by default. The variable is
|
|
|
|
# local to the current scope. Thread local.
|
1998-01-16 07:13:05 -05:00
|
|
|
alias $LAST_READ_LINE $_
|
2004-01-20 00:04:31 -05:00
|
|
|
|
|
|
|
# The destination of output for <tt>Kernel.print</tt>
|
|
|
|
# and <tt>Kernel.printf</tt>. The default value is
|
|
|
|
# <tt>$stdout</tt>.
|
1998-01-16 07:13:05 -05:00
|
|
|
alias $DEFAULT_OUTPUT $>
|
2004-01-20 00:04:31 -05:00
|
|
|
|
|
|
|
# An object that provides access to the concatenation
|
|
|
|
# of the contents of all the files
|
|
|
|
# given as command-line arguments, or <tt>$stdin</tt>
|
|
|
|
# (in the case where there are no
|
2009-03-05 22:56:38 -05:00
|
|
|
# arguments). <tt>$<</tt> supports methods similar to a
|
2004-01-20 00:04:31 -05:00
|
|
|
# +File+ object:
|
|
|
|
# +inmode+, +close+,
|
|
|
|
# <tt>closed?</tt>, +each+,
|
|
|
|
# <tt>each_byte</tt>, <tt>each_line</tt>,
|
|
|
|
# +eof+, <tt>eof?</tt>, +file+,
|
|
|
|
# +filename+, +fileno+,
|
|
|
|
# +getc+, +gets+, +lineno+,
|
2009-03-05 22:56:38 -05:00
|
|
|
# <tt>lineno=</tt>, +path+,
|
2004-01-20 00:04:31 -05:00
|
|
|
# +pos+, <tt>pos=</tt>,
|
|
|
|
# +read+, +readchar+,
|
|
|
|
# +readline+, +readlines+,
|
|
|
|
# +rewind+, +seek+, +skip+,
|
|
|
|
# +tell+, <tt>to_a</tt>, <tt>to_i</tt>,
|
|
|
|
# <tt>to_io</tt>, <tt>to_s</tt>, along with the
|
|
|
|
# methods in +Enumerable+. The method +file+
|
|
|
|
# returns a +File+ object for the file currently
|
|
|
|
# being read. This may change as <tt>$<</tt> reads
|
|
|
|
# through the files on the command line. Read only.
|
1998-01-16 07:13:05 -05:00
|
|
|
alias $DEFAULT_INPUT $<
|
2004-01-20 00:04:31 -05:00
|
|
|
|
|
|
|
# The process number of the program being executed. Read only.
|
1998-01-16 07:13:05 -05:00
|
|
|
alias $PID $$
|
2004-01-20 00:04:31 -05:00
|
|
|
|
|
|
|
# The process number of the program being executed. Read only.
|
1998-01-16 07:13:05 -05:00
|
|
|
alias $PROCESS_ID $$
|
2004-01-20 00:04:31 -05:00
|
|
|
|
|
|
|
# The exit status of the last child process to terminate. Read
|
|
|
|
# only. Thread local.
|
1998-01-16 07:13:05 -05:00
|
|
|
alias $CHILD_STATUS $?
|
2004-01-20 00:04:31 -05:00
|
|
|
|
|
|
|
# A +MatchData+ object that encapsulates the results of a successful
|
|
|
|
# pattern match. The variables <tt>$&</tt>, <tt>$`</tt>, <tt>$'</tt>,
|
|
|
|
# and <tt>$1</tt> to <tt>$9</tt> are all derived from
|
|
|
|
# <tt>$~</tt>. Assigning to <tt>$~</tt> changes the values of these
|
|
|
|
# derived variables. This variable is local to the current
|
2013-02-01 21:47:33 -05:00
|
|
|
# scope.
|
1998-01-16 07:13:05 -05:00
|
|
|
alias $LAST_MATCH_INFO $~
|
2004-01-20 00:04:31 -05:00
|
|
|
|
|
|
|
# If set to any value apart from +nil+ or +false+, all pattern matches
|
|
|
|
# will be case insensitive, string comparisons will ignore case, and
|
|
|
|
# string hash values will be case insensitive. Deprecated
|
1998-01-16 07:13:05 -05:00
|
|
|
alias $IGNORECASE $=
|
2004-01-20 00:04:31 -05:00
|
|
|
|
|
|
|
# An array of strings containing the command-line
|
|
|
|
# options from the invocation of the program. Options
|
|
|
|
# used by the Ruby interpreter will have been
|
|
|
|
# removed. Read only. Also known simply as +ARGV+.
|
1998-01-16 07:13:05 -05:00
|
|
|
alias $ARGV $*
|
2004-01-20 00:04:31 -05:00
|
|
|
|
|
|
|
# The string matched by the last successful pattern
|
|
|
|
# match. This variable is local to the current
|
2013-02-01 21:47:33 -05:00
|
|
|
# scope. Read only.
|
1998-01-16 07:13:05 -05:00
|
|
|
alias $MATCH $&
|
2004-01-20 00:04:31 -05:00
|
|
|
|
|
|
|
# The string preceding the match in the last
|
2009-03-05 22:56:38 -05:00
|
|
|
# successful pattern match. This variable is local to
|
2013-02-01 21:47:33 -05:00
|
|
|
# the current scope. Read only.
|
1998-01-16 07:13:05 -05:00
|
|
|
alias $PREMATCH $`
|
2004-01-20 00:04:31 -05:00
|
|
|
|
|
|
|
# The string following the match in the last
|
2009-03-05 22:56:38 -05:00
|
|
|
# successful pattern match. This variable is local to
|
2013-02-01 21:47:33 -05:00
|
|
|
# the current scope. Read only.
|
1998-01-16 07:13:05 -05:00
|
|
|
alias $POSTMATCH $'
|
2004-01-20 00:04:31 -05:00
|
|
|
|
|
|
|
# The contents of the highest-numbered group matched in the last
|
|
|
|
# successful pattern match. Thus, in <tt>"cat" =~ /(c|a)(t|z)/</tt>,
|
|
|
|
# <tt>$+</tt> will be set to "t". This variable is local to the
|
2013-02-01 21:47:33 -05:00
|
|
|
# current scope. Read only.
|
1998-01-16 07:13:05 -05:00
|
|
|
alias $LAST_PAREN_MATCH $+
|