| class methods | 
| Array | Array( arg ) -> anArray | 
 | Returns arg .to_a.
  | Array(1..5) | » | [1, 2, 3, 4, 5] |  | | Float | Float( arg ) -> aFloat | 
 | Returns arg converted to a float. Numeric types are
      converted directly, nilis converted to0.0, and
      the rest are converted using arg.to_f.
  | Float(1) | » | 1.0 |  
  | Float(nil) | » | 0.0 |  
  | Float("123.456") | » | 123.456 |  | | Integer | Integer( arg ) -> anInteger | 
 | Converts arg to a FixnumorBignum. Numeric types 
      are converted directly (with floating point numbers being
      truncated). If arg is aString, leading radix
      indicators (0,0b, and0x) are honored. This
      behavior is different from that ofString#to_i.
  | Integer(123.999) | » | 123 |  
  | Integer("0x1a") | » | 26 |  
  | Integer(Time.new) | » | 983770240 |  | | String | String( arg ) -> aString | 
 | Converts arg to a Stringby calling itsto_smethod.
  | String(self) | » | "main" |  
  | String(self.type) | » | "Object" |  
  | String(123456) | » | "123456" |  | | ` (backquote) | `cmd` -> aString | 
 | Returns the standard output of running cmd in a
      subshell. The built-in syntax %x{...}described
      on page 75 uses this method.
  | `date` | » | "Sun Mar  4 23:30:40 CST 2001\n" |  
  | `ls testdir`.split[1] | » | "main.rb" |  | | abort | abort | 
 | Terminate execution immediately, effectively by calling Kernel.exit(1). | | at_exit | at_exit { block }
-> aProc | 
 | Converts block to a Procobject (and therefore binds
      it at the point of call) and registers it for      
      execution when the program exits. If multiple handlers are
      registered, they are executed in reverse order of registration.produces:| 
def do_at_exit(str1)
  at_exit { print str1 }
end
at_exit { puts "cruel world" }
do_at_exit("goodbye ")
exit
 | 
 | | autoload | autoload( aModule, aFile )
        -> nil | 
 | Registers aFile to be loaded (using Kernel::require) the first time that aModule (which
      may be aStringor a symbol) is accessed.| 
autoload :MyModule, "/usr/local/lib/modules/my_module.rb"
 | 
 | | binding | binding -> aBinding | 
 | Returns a Bindingobject, describing the variable and method 
      bindings at the point of call. This object can be used when callingevalto execute the evaluated command in this
      environment. Also see the description ofBindingbeginning on page 295.
| def getBinding(param) |  
|   return binding |  
| end |  
| b = getBinding("hello") |  
  | eval "param", b | » | "hello" |  | | block_given? | block_given? -> trueorfalse | 
 | Returns trueifyieldwould execute a block
      in the current context.
| def try |  
|   if block_given? |  
|     yield |  
|   else |  
|     "no block" |  
|   end |  
| end |  
  | try | » | "no block" |  
  | try { "hello" } | » | "hello" |  
| try do |  
|   "hello" |  
| end |  | | callcc | callcc {| cont | block }
 -> anObject | 
 | Generates a Continuationobject, which it passes to the associated
      block. Performing a cont.callwill cause thecallccto return (as will falling through the end of
      the block). The value returned by thecallccis the
      value of the block, or the value passed to
      cont.call. SeeContinuationon page 298 for more details. Also seeKernel::throwfor an alternative mechanism for unwinding a
      call stack. | | caller | caller( [anInteger] )
        -> anArray | 
 | Returns the current execution
      stack---an array containing strings in the form
      ``file:line'' or ``file:line: in `method'''. The
      optional anInteger parameter determines the number of
      initial stack entries to omit from the result. 
| def a(skip) |  
|   caller(skip) |  
| end |  
| def b(skip) |  
|   a(skip) |  
| end |  
| def c(skip) |  
|   b(skip) |  
| end |  
  | c(0) | » | ["prog:2:in `a'", "prog:5:in `b'", "prog:8:in `c'", "prog:10"] |  
  | c(1) | » | ["prog:5:in `b'", "prog:8:in `c'", "prog:11"] |  
  | c(2) | » | ["prog:8:in `c'", "prog:12"] |  
  | c(3) | » | ["prog:13"] |  | | catch | catch( symbol ) {|  | block }
        -> anObject | 
 | catchexecutes its block. If athrowis
      executed, Ruby searches up its stack for acatchblock with a tag
      corresponding to thethrow's symbol. If found, that block is
      terminated, andcatchreturns the value given tothrow.  Ifthrowis not called,
      the block terminates normally, and
      the value ofcatchis the value of the last expression
      evaluated.catchexpressions may be nested, and thethrowcall need not be in lexical scope.produces:| 
def routine(n)
  puts n
  throw :done if n <= 0
  routine(n-1)
end
catch(:done) { routine(3) }
 | 
 | | chomp | chomp( [aString] )
        -> $_ or aString | 
 | Equivalent to $_ = $_.chomp(aString).
      SeeString#chompon page 372.
| $_ = "now\n" |  
  | chomp | » | "now" |  
  | $_ | » | "now" |  
  | chomp "ow" | » | "n" |  
  | $_ | » | "n" |  
  | chomp "xxx" | » | "n" |  
  | $_ | » | "n" |  | | chomp! | chomp!( [aString] )
        -> $_ or nil | 
 | Equivalent to $_.chomp!(aString).
      SeeString#chomp!
| $_ = "now\n" |  
  | chomp! | » | "now" |  
  | $_ | » | "now" |  
  | chomp! "x" | » | nil |  
  | $_ | » | "now" |  | | chop | chop -> aString | 
 | Equivalent to ($_.dup).chop!, exceptnilis never
      returned.
      SeeString#chop!on page 372.
| a  =  "now\r\n" |  
| $_ = a |  
  | chop | » | "now" |  
  | $_ | » | "now" |  
  | chop | » | "no" |  
  | chop | » | "n" |  
  | chop | » | "" |  
  | chop | » | "" |  
  | a | » | "now\r\n" |  | | chop! | chop! -> $_ or nil | 
 | Equivalent to $_.chop!.
| a  = "now\r\n" |  
| $_ = a |  
  | chop! | » | "now" |  
  | chop! | » | "no" |  
  | chop! | » | "n" |  
  | chop! | » | "" |  
  | chop! | » | nil |  
  | $_ | » | "" |  
  | a | » | "" |  | | eval | eval( aString
        [, aBinding [file [line]]])
        -> anObject | 
 | Evaluates the Ruby expression(s) in aString. If
      aBinding is given, the evaluation is performed in its
      context.      
      The binding may be a Bindingobject or aProcobject. If the optional file and line parameters
      are present, they will be used when reporting syntax errors.
| def getBinding(str) |  
|   return binding |  
| end |  
| str = "hello" |  
  | eval "str + ' Fred'" | » | "hello Fred" |  
  | eval "str + ' Fred'", getBinding("bye") | » | "bye Fred" |  | | exec | exec( command [, args]) | 
 | Replaces the current process by running the given external
      command.      
      If execis given a single
      argument, that argument is taken as a line that is subject to
      shell expansion before being executed. If multiple arguments are
      given, the second and subsequent arguments are passed as
      parameters to command with no shell expansion. If the
      first argument is a two-element array, the first element is the
      command to be executed, and the second argument is used as theargv[0]value, which may show up in process listings. In MSDOS
      environments, the command is executed in a subshell; otherwise,
      one of theexec(2)system calls is used, so the running
      command may inherit some of the environment of the original
      program (including open file descriptors).| 
exec "echo *"       # echoes list of files in current directory
# never get here
exec "echo", "*"    # echoes an asterisk
# never get here
 | 
 | | exit | exit( anInteger=0 ) | 
 | Initiates the termination of the Ruby script by raising the SystemExitexception. This exception may be caught. The
      optional parameter is used to return a status code to the
      invoking environment.produces:| 
begin
  exit
  puts "never get here"
rescue SystemExit
  puts "rescued a SystemExit exception"
end
puts "after begin block"
 | 
 Just prior to termination, Ruby executes
      any| 
rescued a SystemExit exception
after begin block
 | 
 at_exitfunctions and runs any object finalizers (seeObjectSpacebeginning on page 434).produces:| 
at_exit { puts "at_exit function" }
ObjectSpace.define_finalizer(self,  proc { puts "in finalizer" })
exit
 | 
 | 
at_exit function
0x4019ac90
n finals=>0
 | 
 | | exit! | exit!( anInteger=-1 ) | 
 | Similar to Kernel::exit, but exception handling,at_exitfunctions, and finalizers are bypassed. | | fail | fail fail( aString )
 fail( anException [, aString
            [anArray]] )
 | 
 | Synonym for Kernel::raise. | | fork | fork [{ block }
] -> aFixnum
        or nil | 
 | Creates a subshell. If a block is specified, that block is run
      in the subshell, and the subshell terminates with a status of
      zero. Otherwise, the forkcall returns twice, once in
      the parent, returning the  process id of the child, and once in
      the child, returningnil. The child process can
      exit usingKernel::exit!to avoid running anyat_exitfunctions. The parent process should useProcess::waitto collect the termination statuses of its
      children; otherwise, the operating system may accumulate zombie
      processes.produces:| 
fork do
  3.times {|i| puts "Child: #{i}" }
end
3.times {|i| puts "Parent: #{i}" }
Process.wait
 | 
 | 
Parent: 0
Child: 0
Child: 1
Parent: 1
Parent: 2
Child: 2
 | 
 | | format | format( aString [,
          anObject]* ) -> aString | 
 | Synonym for Kernel::sprintf. | | gets | gets( aString= $/)
        -> aString ornil | 
 | Returns (and assigns to $_) the next line from
      the list of files inARGV(or$*), or
      from standard input if no files are present on the command line.
      Returnsnilat end of file. 
      The optional argument specifies the
      record separator. The separator is
      included with the contents of each record. A separator ofnilreads the entire contents, and a zero-length separator reads the
      input one paragraph at a time, where paragraphs are divided
      by two consecutive newlines. If multiple filenames are
      present inARGV,gets(nil)will read the
      contents one file at a time.produces:| 
ARGV << "testfile"
print while gets
 | 
 | 
This is line one
This is line two
This is line three
And so on...
 | 
 | | global_variables | global_variables
        -> anArray | 
 | Returns an array of the names of global variables. 
  | global_variables.grep /std/ | » | ["$stderr", "$stdout", "$stdin"] |  | | gsub | gsub( pattern, replacement )
          -> aString gsub( pattern ) {|  | block }
          -> aString
 | 
 | Equivalent to $_.gsub..., except that$_receives the modified result.
| $_ = "quick brown fox" |  
  | gsub /[aeiou]/, '*' | » | "q**ck br*wn f*x" |  
  | $_ | » | "q**ck br*wn f*x" |  | | gsub! | gsub!( pattern, replacement )
          -> aString or nilgsub!( pattern ) {|  | block }
          -> aString or
 nil | 
 | Equivalent to Kernel::gsub, exceptnilis returned if$_is not modified.
| $_ = "quick brown fox" |  
  | gsub! /cat/, '*' | » | nil |  
  | $_ | » | "quick brown fox" |  | | iterator? | iterator? -> trueorfalse | 
 | Synonym for Kernel::block_given?. Theiterator?method will be removed in Ruby 1.8. | | lambda | lambda {|  | block }
 -> aProc | 
 | Synonym for Kernel::proc. | | load | load( aFileName,
        wrap= false) ->true | 
 | Loads and executes the Ruby program in the file
      aFileName. If the filename does not resolve to an absolute path, the
      file is searched for in the library directories listed in $:. If the optional wrap parameter istrue, the loaded script will be executed under an
      anonymous module, protecting the calling program's global
      namespace. Any local variables in the loaded file will not be
      propagated to the loading environment. | | local_variables | local_variables
        -> anArray | 
 | Returns the names of the current local variables. 
| fred = 1 |  
| for i in 1..10 |  
|    # ... |  
| end |  
  | local_variables | » | ["fred", "i"] |  | | loop | loop {|  | block } | 
 | Repeatedly executes the block. | 
loop {
  print "Input: "
  break if !gets or $_ =~ /^qQ/
  # ...
}
 | 
 | | open | open( aString
                [, aMode [perm]] )
                -> anIO or nilopen( aString
                [, aMode [perm]] ) {| anIO | block }
                ->
 nil | 
 | Creates an IOobject connected to the given stream, file, 
         or subprocess.                  
         If aString does not start with a pipe character
         (``|''), treat it as the name of a file to open using the
         specified mode defaulting to ``r'' (see the table of
         valid modes on page 331). If a file is being
         created, its initial permissions may be set using the integer 
         third parameter.
         If a block is specified, it will be invoked with theFileobject as a parameter, and the file will be automatically
         closed when the block terminates. The call always returnsnilin this case.
         If aString starts with a pipe character, a subprocess
         is created, connected to the caller by a pair of pipes. The
         returnedIOobject may be used to write to the standard
         input and read from the standard output of this subprocess.
         If the command following the ``|'' is a single minus sign,
         Ruby forks, and this subprocess is connected to the parent.
         In the subprocess, theopencall returnsnil. If
         the command is not ``-'', the subprocess runs the command. If 
         a block is associated with anopen("|-")call, that
         block will be run twice---once in the parent and once in the
         child. The block parameter will be anIOobject in the
         parent andnilin the child. The parent'sIOobject will
         be connected to the child's$stdinand$stdout.
         The subprocess will be terminated at the end of the
         block.produces:
         Open a subprocess and read its output:| 
open("testfile") do |f|
  print f.gets
end
 | 
 produces:| 
cmd = open("|date")
print cmd.gets
cmd.close
 | 
 Open a subprocess running the same Ruby program:| 
Sun Mar  4 23:30:41 CST 2001
 | 
 produces:
         Open a subprocess using a block to receive the I/O object:| 
f = open("|-", "w+")
if f == nil
  puts "in Child"
  exit
else
  puts "Got: #{f.gets}"
end
 | 
 produces:| 
open("|-") do |f|
  if f == nil
    puts "in Child"
  else
    puts "Got: #{f.gets}"
  end
end
 | 
 | | p | p( [anObject]+ )
      -> nil | 
 | For each object, directly writes anObject.inspectfollowed by
      the current output record separator to the program's standard
      output.pbypasses the Ruby I/O libraries.
produces: | | print | print( [anObject]* )
        -> nil | 
 | Prints each object in turn to $defout. If the
      output field separator ($,)
      is notnil, its contents will appear
      between each field.      
      If the output record separator
      ($\)
      is notnil, it will be appended to the output. If 
      no arguments are given, prints$_. Objects that aren't
      strings will be converted by calling theirto_smethod.produces:| 
print "cat", [1,2,3], 99, "\n"
$, = ", "
$\ = "\n"
print "cat", [1,2,3], 99
 | 
 | 
cat12399
cat, 1, 2, 3, 99
 | 
 | | printf | printf( anIO, aString [, anObject]* )
          -> nilprintf( aString [, anObject]* )
          ->
 nil | 
 | Equivalent to:
anIO. write sprintf(aString, anObject ...)or
 
 $defout.write sprintf(aString, anObject ...) | | proc | proc { block }
-> aProc | 
 | Creates a new procedure object from the given block. Equivalent
      to Proc::new.
| aProc = proc { "hello" } |  
  | aProc.call | » | "hello" |  | | putc | putc( anInteger ) -> anInteger | 
 | Equivalent to $defout.putc(anInteger). | | puts | puts( [args]* ) -> nil | 
 | Equivalent to $defout.puts(args). | | raise | raise raise( aString )
 raise( anException [, aString
            [anArray]] )
 | 
 | With no arguments, raises the
      exception in $!or raises aRuntimeErrorif$!isnil.      
      With a singleStringargument, raises aRuntimeErrorwith the string as a message. Otherwise, the
      first parameter should be the name of anExceptionclass
      (or an object that returns anExceptionwhen sentexception). The
      optional second parameter sets the message associated with the
      exception, and the third parameter is an array of callback
      information. Exceptions are caught by therescueclause ofbegin...endblocks.| 
raise "Failed to create socket"
raise ArgumentError, "No parameters", caller
 | 
 | | rand | rand( max=0 )
        -> aNumber | 
 | Converts max to an integer using max1 =
      max .to_i.abs.
      If the result is zero, returns a pseudorandom floating point
      number greater than or equal to 0.0 and less than
      1.0. Otherwise, returns a pseudorandom integer greater than or
      equal to zero and less than max1.Kernel::srandmay be
      used to ensure repeatable sequences of random numbers between
      different runs of the program.
  | srand 1234 | » | 0 |  
  | [ rand,  rand ] | » | [0.7408769294, 0.2145348572] |  
  | [ rand(10), rand(1000) ] | » | [3, 323] |  
  | srand 1234 | » | 1234 |  
  | [ rand,  rand ] | » | [0.7408769294, 0.2145348572] |  | | readline | readline( [aString= $/] )
        -> aString | 
 | Equivalent to Kernel::gets, exceptreadlineraisesEOFErrorat end of file. | | readlines | readlines( [aString= $/] )
        -> anArray | 
 | Returns an array containing the lines returned by
      calling Kernel.gets(aString)until the end of file. | | require | require( aString )
        -> trueorfalse | 
 | Ruby tries to load the library named aString, returning trueif successful. If the filename does not resolve to an
      absolute path, it will be searched for in the directories listed 
      in$:. If the file has the extension
      ``.rb'', it is loaded as a source file; if the extension is
      ``.so'', ``.o'', or ``.dll'',[Or whatever the default
        shared library extension is on the current platform.] Ruby
      loads the shared library as a Ruby extension. Otherwise, Ruby
      tries adding ``.rb'', ``.so'', and so on to the name. The name
      of the loaded feature is added to the array in$". A
      feature will not be loaded if it already appears in$".requirereturnstrueif the feature was
      successfully loaded.| 
require "my-library.rb"
require "db-driver"
 | 
 | | scan | scan( pattern ) -> anArray scan( pattern ) {|  | block }
 -> $_
 | 
 | Equivalent to calling $_.scan. SeeString#scanon page 378. | | select | select( readArray [,
          writeArray
          [errorArray [timeout]]] )
        -> anArray or nil | 
 | Performs
      a low-level selectcall, which waits for data to
      become available from input/output devices. The first three
      parameters are arrays ofIOobjects ornil. The last is a
      timeout in seconds, which should be anIntegeror aFloat.  The call waits for data to become available for any
      of theIOobjects in readArray, for buffers to have
      cleared sufficiently to enable writing to any of the devices in
      writeArray, or for an error to occur on the devices in
      errorArray. If one or more of these conditions are met, the
      call returns a three-element array containing arrays of theIOobjects that were ready.  Otherwise, if there is no
      change in status for timeout seconds, the call returnsnil. If all parameters arenil, the current thread sleeps forever.
  | select( [$stdin], nil, nil, 1.5 ) | » | [[#<IO:0x4019202c>], [], []] |  | | set_trace_func | set_trace_func( aProc ) -> aProc set_trace_func(
 nil) ->nil | 
 | Establishes aProc as the handler for tracing, or disables
      tracing if the parameter is nil. aProc
      takes up to six parameters: an event name, a filename, a line
      number, an object id, a binding, and the name of a
      class. aProc is invoked whenever an event
      occurs. Events are:c-call(call a C-language routine),c-return(return from a C-language routine),call(call a Ruby method),class(start a class or module definition),end(finish a class or module definition),line(execute code on a new line),raise(raise an exception), andreturn(return from a Ruby method).
      Tracing is disabled within the context of aProc.
      See the example starting on page 271 for more
      information. | | singleton_method_added | singleton_method_added( aFixnum ) -> nil | 
 | Invoked with a symbol id whenever a singleton method is added to 
      a module or a class. The default implementation in Kernelignores this, but subclasses may override the method to provide
      specialized functionality.produces:| 
class Test
  def Test.singleton_method_added(id)
    puts "Added #{id.id2name} to Test"
  end
  def a() end
  def Test.b() end
end
def Test.c() end
 | 
 | 
Added singleton_method_added to Test
Added b to Test
Added c to Test
 | 
 | | sleep | sleep( [aNumeric] )
        -> aFixnum | 
 | Suspends the current thread for aNumber seconds (which may be a Floatwith fractional seconds). Returns the actual number of seconds
      slept (rounded), which may be less than that asked for if the
      thread was interrupted by aSIGALRM, or if another thread
      callsThread#run. An argument of zero causessleepto sleep forever.
  | Time.new | » | Sun Mar 04 23:30:41 CST 2001 |  
  | sleep 1.2 | » | 2 |  
  | Time.new | » | Sun Mar 04 23:30:43 CST 2001 |  
  | sleep 1.9 | » | 2 |  
  | Time.new | » | Sun Mar 04 23:30:45 CST 2001 |  | | split | split( [pattern
          [limit]] ) -> anArray | 
 | Equivalent to $_.split(pattern, limit). SeeString#spliton page 379. | | sprintf | sprintf( aFormatString 
                [, arguments]* ) -> aString | 
 | Returns the string resulting
      from applying  aFormatString to any additional arguments.
      Within the format string, any characters other than format
      sequences are copied to the result.
      A format sequence consists of a percent sign, followed by
      optional flags, width, and precision indicators, then terminated
      with a field type character. The field type controls how the
      corresponding sprintfargument is to be interpreted,
      while the flags modify that interpretation.
      The flag characters are shown in Table
      23.1 on page 428, and the field type characters are listed 
      in Table 23.2.
      The field width is an optional integer, followed optionally by a 
      period and a precision. The width specifies the minimum number
      of characters that will be written to the result for this
      field. For numeric fields, the precision controls the number of
      decimal places displayed. For string fields, the precision
      determines the maximum number of characters to be copied from
      the string. (Thus, the format sequence%10.10swill always 
      contribute exactly ten characters to the result.)| sprintfflag characters
  | Flag | Applies to | Meaning |  
  | (space)![[visible space]](visible_space.gif) | bdeEfgGioxXu | Leave a
          space at the start of positive numbers. |  
  | # | beEfgGoxX | Use an alternative format. For the
          conversions `o', `x', `X', and `b', prefix the result with
          ``0'', ``0x'', ``0X'', and ``0b'', respectively. For `e',
          `E', `f', `g', and 'G', force a decimal point to be added,
          even if no digits follow. For `g' and 'G', do not remove
          trailing zeros. |  
  | + | bdeEfgGioxXu | Add a leading plus sign to
          positive numbers. |  
  | - | all | Left-justify the result of this conversion. |  
  | 0(zero) | all | Pad with zeros, not spaces. |  
  | * | all | Use the next argument as the field width. If
          negative, left-justify the result. If the asterisk is
          followed by a number and a dollar sign, use 
          the indicated argument as the width. |  |  |  | 
 | sprintffield types
  | Field | Conversion |  
  | b | Convert argument as a binary number. |  
  | c | Argument is the numeric code for a single character. |  
  | d | Convert argument as a decimal number. |  
  | E | Equivalent to `e', but uses an uppercase E to indicate
          the exponent. |  
  | e | Convert floating point argument into exponential notation 
          with one digit before the decimal point. The precision
          determines the number of fractional digits (defaulting to six). |  
  | f | Convert floating point argument as [, 
          where the precision determines the number of digits after
          the decimal point.![[visible space]](visible_space.gif) -]ddd.ddd |  
  | G | Equivalent to `g', but use an uppercase `E' in exponent 
          form. |  
  | g | Convert a floating point number using exponential form
          if the exponent is less than -4 or greater than or
          equal to the precision, or in d.ddddform otherwise. |  
  | i | Identical to `d'. |  
  | o | Convert argument as an octal number. |  
  | s | Argument is a string to be substituted. If the format
          sequence contains a precision, at most that many characters
          will be copied. |  
  | u | Treat argument as an unsigned decimal number. |  
  | X | Convert argument as a hexadecimal number using uppercase letters. |  
  | x | Convert argument as a hexadecimal number. |  |  |  | 
 
  | sprintf("%d %04x", 123, 123) | » | "123![[visible space]](visible_space.gif) 007b" |  
  | sprintf("%08b '%4s'", 123, 123) | » | "01111011![[visible space]](visible_space.gif) ' ![[visible space]](visible_space.gif) 123'" |  
  | sprintf("%*2$s %d", "hello", 10) | » | "![[visible space]](visible_space.gif) ![[visible space]](visible_space.gif) ![[visible space]](visible_space.gif) ![[visible space]](visible_space.gif) ![[visible space]](visible_space.gif) hello ![[visible space]](visible_space.gif) 10" |  
  | sprintf("%*2$s %d", "hello", -10) | » | "hello![[visible space]](visible_space.gif) ![[visible space]](visible_space.gif) ![[visible space]](visible_space.gif) ![[visible space]](visible_space.gif) ![[visible space]](visible_space.gif) ![[visible space]](visible_space.gif) -10" |  
  | sprintf("%+g:% g:%-g", 1.23, 1.23, 1.23) | » | "+1.23:![[visible space]](visible_space.gif) 1.23:1.23" |  | | srand | srand( [aNumber] )
        -> oldSeed | 
 | Seeds the pseudorandom number generator to the value of
      aNumber. to_i.abs. If aNumber is omitted or zero,
      seeds the generator using a combination of the time, the process 
      id, and a sequence number. (This is also the behavior ifKernel::randis called without previously callingsrand, but without the sequence.)
      By setting the seed to a known value, scripts can be made
      deterministic during testing. The previous seed value is
      returned. Also seeKernel::randon page 425. | | sub | sub( pattern, replacement )
            -> $_ sub( pattern ) { block }
            -> $_
 | 
 | Equivalent to $_.sub(args), except that$_will be updated if substitution occurs. | | sub! | sub!( pattern, replacement )
            -> $_ or nilsub!( pattern ) { block }
            -> $_ or
 nil | 
 | Equivalent to $_.sub!(args). | | syscall | syscall( aFixnum
        [, args]* )
        -> anInteger | 
 | Calls the operating system function identified by aFixnum, 
      passing in the arguments, which must be either Stringobjects, orIntegerobjects that ultimately fit within a nativelong. 
      Up to nine parameters may be passed (14 on the
      Atari-ST). The function identified
      by Fixnum is system dependent. On some Unix systems, the
      numbers may be obtained from a header file calledsyscall.h.produces:| 
syscall 4, 1, "hello\n", 6   # '4' is write(2) on our box
 | 
 | | system | system( aCmd [, args]* )
        -> trueorfalse | 
 | Executes aCmd in a subshell, returning trueif the 
      command was found and ran successfully,falseotherwise. A detailed error code is available in$?. The 
      arguments are processed in the same way as forKernel::execon page 419.produces:| 
system("echo *")
system("echo", "*")
 | 
 | | test | test(aCmd, file1 [, file2] )
        -> anObject | 
 | Uses the integer aCmd to perform various tests on
      file1 (Table 23.3 on page 430) or on file1 and
      file2 (Table 23.4). | File tests with a single argument 
  | Integer | Description | Returns |  
  | ?A | Last access time for file1 | Time |  
  | ?b | True if file1 is a block device | trueorfalse |  
  | ?c | True if file1 is a character device | trueorfalse |  
  | ?C | Last change time for file1 | Time |  
  | ?d | True if file1 exists and is a directory | trueorfalse |  
  | ?e | True if file1 exists | trueorfalse |  
  | ?f | True if file1 exists and is a regular file | trueorfalse |  
  | ?g | True if file1 has the setgidbit set (false under
          NT) | trueorfalse |  
  | ?G | True if file1 exists and has a group ownership equal to
          the caller's group | trueorfalse |  
  | ?k | True if file1 exists and has the sticky bit set | trueorfalse |  
  | ?l | True if file1 exists and is a symbolic link | trueorfalse |  
  | ?M | Last modification time for file1 | Time |  
  | ?o | True if file1 exists and is owned by the caller's
          effective uid | trueorfalse |  
  | ?O | True if file1 exists and is owned by the caller's
          real uid | trueorfalse |  
  | ?p | True if file1 exists and is a fifo | trueorfalse |  
  | ?r | True if file is readable by the effective uid/gid of the
          caller | trueorfalse |  
  | ?R | True if file is readable by the real uid/gid of the
          caller | trueorfalse |  
  | ?s | If file1 has nonzero size, return the size, otherwise
          return nil | Integer or nil |  
  | ?S | True if file1 exists and is a socket | trueorfalse |  
  | ?u | True if file1 has the setuid bit set | trueorfalse |  
  | ?w | True if file1 exists and is writable by the effective
          uid/gid | trueorfalse |  
  | ?W | True if file1 exists and is writable by the real
          uid/gid | trueorfalse |  
  | ?x | True if file1 exists and is executable by the effective
          uid/gid | trueorfalse |  
  | ?X | True if file1 exists and is executable by the real
          uid/gid | trueorfalse |  
  | ?z | True if file1 exists and has a zero length | trueorfalse |  |  |  | 
 | File tests with two arguments 
  | Integer | Description |  
  | ?- | True if file1 is a hard link to file2 |  
  | ?= | True if the modification times of file1 and file2 are
          equal |  
  | ?< | True if the modification time of file1 is prior to that
          of file2 |  
  | ?> | True if the modification time of file1 is after that
          of file2 |  |  |  | 
 | | throw | throw( aSymbol
        [, anObject] ) | 
 | Transfers control to the end of the active catchblock
      waiting for aSymbol. RaisesNameErrorif
      there is nocatchblock
      for the symbol. The optional second
      parameter supplies a return value for thecatchblock,
      which otherwise defaults tonil. For examples, seeKernel::catchon page 417. | | trace_var | trace_var( aSymbol, aCmd ) -> niltrace_var( aSymbol ) {| val | block }
          ->
 nil | 
 | Controls tracing of assignments to global variables. The
      parameter aSymbol identifies the variable (as either a
      string name or a symbol identifier).
      cmd (which may be a string or a Procobject) or block
      is executed whenever the variable is assigned. The block orProcobject receives the variable's new value as a
      parameter. Also seeKernel::untrace_var.produces:| 
trace_var :$_, proc {|v| puts "$_ is now '#{v}'" }
$_ = "hello"
$_ = ' there'
 | 
 | 
$_ is now 'hello'
$_ is now ' there'
 | 
 | | trap | trap( signal, cmd ) -> anObject trap( signal ) {|  | block }
 -> anObject
 | 
 | Specifies the handling of signals. The first parameter is a
      signal name (a string such as ``SIGALRM'', ``SIGUSR1'', and so on)
      or a signal number. The characters ``SIG'' may be omitted from
      the signal name. The command or block specifies code to be run
      when the signal is raised. If the command is the string
      ``IGNORE'' or ``SIG_IGN'', the signal will be ignored. If the
      command is ``DEFAULT'' or ``SIG_DFL'', the operating system's
      default handler will be invoked. If the command is ``EXIT'', the 
      script will be terminated by the signal. Otherwise, the given
      command or block will be run.
      The special signal name ``EXIT'' or signal
      number zero will be invoked just prior to program termination. trapreturns the previous handler for the given signal.produces:| 
trap 0, proc { puts "Terminating: #{$$}" }
trap("CLD") { puts "Child died" }
fork && Process.wait
 | 
 | 
Terminating: 16422
Child died
Terminating: 16421
 | 
 | | untrace_var | untrace_var( aSymbol [,
          aCmd] ) -> anArray or nil | 
 | Removes tracing
      for the specified command on the given global variable and
      returns nil. If no command is specified, removes all tracing for
      that variable and returns an array containing the commands
      actually removed. |