Sr.No. |
Methods & Description |
1 |
abort
Terminates program. If an exception is raised (i.e., $! isn"t nil), its error message is displayed. |
2 |
Array( obj)
Returns obj after converting it to an array using to_ary or to_a. |
3 |
at_exit {...}
Registers a block for execution when the program exits. Similar to END statement, but END statement registers the block only once. |
4 |
autoload( classname, file)
Registers a class classname to be loaded from file the first time it"s used. classname may be a string or a symbol. |
5 |
binding
Returns the current variable and method bindings. The Binding object that is returned may be passed to the eval method as its second argument. |
6 |
block_given?
Returns true if the method was called with a block. |
7 |
callcc {| c|...}
Passes a Continuation object c to the block and executes the block. callcc can be used for global exit or loop construct. |
8 |
caller([ n])
Returns the current execution stack in an array of the strings in the form file:line. If n is specified, returns stack entries from nth level on down. |
9 |
catch( tag) {...}
Catches a nonlocal exit by a throw called during the execution of its block. |
10 |
chomp([ rs = $/])
Returns the value of variable $_ with the ending newline removed, assigning the result back to $_. The value of the newline string can be specified with rs. |
11 |
chomp!([ rs = $/])
Removes newline from $_, modifying the string in place. |
12 |
chop
Returns the value of $_ with its last character (one byte) removed, assigning the result back to $_. |
13 |
chop!
Removes the last character from $_, modifying the string in place. |
14 |
eval( str[, scope[, file, line]])
Executes str as Ruby code. The binding in which to perform the evaluation may be specified with scope. The filename and line number of the code to be compiled may be specified using file and line. |
15 |
exec( cmd[, arg...])
Replaces the current process by running the command cmd. If multiple arguments are specified, the command is executed with no shell expansion. |
16 |
exit([ result = 0])
Exits program, with result as the status code returned. |
17 |
exit!([ result = 0])
Kills the program bypassing exit handling such as ensure, etc. |
18 |
fail(...)
See raise(...) |
19 |
Float( obj)
Returns obj after converting it to a float. Numeric objects are converted directly; nil is converted to 0.0; strings are converted considering 0x, 0b radix prefix. The rest are converted using obj.to_f. |
20 |
fork
fork {...}
Creates a child process. nil is returned in the child process and the child process" ID (integer) is returned in the parent process. If a block is specified, it"s run in the child process. |
21 |
format( fmt[, arg...])
See sprintf. |
22 |
gets([ rs = $/])
Reads the filename specified in the command line or one line from standard input. The record separator string can be specified explicitly with rs. |
23 |
global_variables
Returns an array of global variable names. |
24 |
gsub( x, y)
gsub( x) {...}
Replaces all strings matching x in $_ with y. If a block is specified, matched strings are replaced with the result of the block. The modified result is assigned to $_. |
25 |
gsub!( x, y)
gsub!( x) {...}
Performs the same substitution as gsub, except the string is changed in place. |
26 |
Integer( obj)
Returns obj after converting it to an integer. Numeric objects are converted directly; nil is converted to 0; strings are converted considering 0x, 0b radix prefix. The rest are converted using obj.to_i. |
27 |
lambda {| x|...}
proc {| x|...}
lambda
proc
Converts a block into a Proc object. If no block is specified, the block associated with the calling method is converted. |
28 |
load( file[, private = false])
Loads a Ruby program from file. Unlike require, it doesn"t load extension libraries. If private is true, the program is loaded into an anonymous module, thus protecting the namespace of the calling program. |
29 |
local_variables
Returns an array of local variable names. |
30 |
loop {...}
Repeats a block of code. |
31 |
open( path[, mode = "r"])
open( path[, mode = "r"]) {| f|...}
Opens a file. If a block is specified, the block is executed with the opened stream passed as an argument. The file is closed automatically when the block exits. If path begins with a pipe |, the following string is run as a command, and the stream associated with that process is returned. |
32 |
p( obj)
Displays obj using its inspect method (often used for debugging). |
33 |
print([ arg...])
Prints arg to $defout. If no arguments are specified, the value of $_ is printed. |
34 |
printf( fmt[, arg...])
Formats arg according to fmt using sprintf and prints the result to $defout. For formatting specifications, see sprintf for detail. |
35 |
proc {| x|...}
proc
See lamda. |
36 |
putc( c)
Prints one character to the default output ($defout). |
37 |
puts([ str])
Prints string to the default output ($defout). If the string doesn"t end with a newline, a newline is appended to the string. |
38 |
raise(...)
fail(...)
Raises an exception. Assumes RuntimeError if no exception class is specified. Calling raise
without arguments in a rescue clause re-raises the exception. Doing so outside a rescue clause raises a message-less RuntimeError. fail is an obsolete name for raise. |
39 |
rand([ max = 0])
Generates a pseudo-random number greater than or equal to 0 and less than max. If max is either not specified or is set to 0, a random number is returned as a floating-point number greater than or equal to 0 and less than 1. srand may be used to initialize pseudo-random stream. |
40 |
readline([ rs = $/])
Equivalent to gets except it raises an EOFError exception on reading EOF. |
41 |
readlines([ rs = $/])
Returns an array of strings holding either the filenames specified as command-line arguments or the contents of standard input. |
42 |
require( lib)
Loads the library (including extension libraries) lib when it"s first called. require will not load the same library more than once. If no extension is specified in lib, require tries to add .rb,.so, etc., to it. |
43 |
scan( re)
scan( re) {|x|...}
Equivalent to $_.scan. |
44 |
select( reads[, writes = nil[, excepts = nil[, timeout = nil]]])
Checks for changes in the status of three types of IO objects input, output, and exceptions which are passed as arrays of IO objects. nil is passed for arguments that don"t need checking. A three-element array containing arrays of the IO objects for which there were changes in status is returned. nil is returned on timeout. |
45 |
set_trace_func( proc)
Sets a handler for tracing. proc may be a string or proc object. set_trace_func is used by the debugger and profiler. |
46 |
sleep([ sec])
Suspends program execution for sec seconds. If sec isn"t specified, the program is suspended forever. |
47 |
split([ sep[, max]])
Equivalent to $_.split. |
48 |
sprintf( fmt[, arg...])
format( fmt[, arg...])
Returns a string in which arg is formatted according to fmt. Formatting specifications are essentially the same as those for sprintf in the C programming language. Conversion specifiers (% followed by conversion field specifier) in fmt are replaced by formatted string of corresponding argument. A list of conversion filed is given below in next section. |
49 |
srand([ seed])
Initializes an array of random numbers. If seed isn"t specified, initialization is performed using the time and other system information for the seed. |
50 |
String( obj)
Returns obj after converting it to a string using obj.to_s. |
51 |
syscall( sys[, arg...])
Calls an operating system call function specified by number sys. The numbers and meaning of sys is system-dependant. |
52 |
system( cmd[, arg...])
Executes cmd as a call to the command line. If multiple arguments are specified, the command is run directly with no shell expansion. Returns true if the return status is 0 (success). |
53 |
sub( x, y)
sub( x) {...}
Replaces the first string matching x in $_ with y. If a block is specified, matched strings are replaced with the result of the block. The modified result is assigned to $_. |
54 |
sub!( x, y)
sub!( x) {...}
Performs the same replacement as sub, except the string is changed in place. |
55 |
test( test, f1[, f2])
Performs various file tests specified by the character test. In order to improve readability, you should use File class methods (for example File::readable?) rather than this function. A list of arguments is given below in next section. |
56 |
throw( tag[, value = nil])
Jumps to the catch function waiting with the symbol or string tag. value is the return value to be used by catch. |
57 |
trace_var( var, cmd)
trace_var( var) {...}
Sets tracing for a global variable. The variable name is specified as a symbol. cmd may be a string or Proc object. |
58 |
trap( sig, cmd)
trap( sig) {...}
Sets a signal handler. sig may be a string (like SIGUSR1) or an integer. SIG may be omitted from signal name. Signal handler for EXIT signal or signal number 0 is invoked just before process termination. |
59 |
untrace_var( var[, cmd])
Removes tracing for a global variable. If cmd is specified, only that command is removed. |