Ruby Built-in Methods Functions

EditRocket provides the following information on Built-in Methods functions in the Ruby source code builder.

at_exit - Register the block for clean-up to execute at the interpreter termination.

autoload(module, file) - Specifies file to be loaded using the method require, when module accessed for the first time.

binding - Returns the data structure of the variable/method binding.

caller([level]) - Returns the context information of current call in the form used for the variable $@.

catch (tag) {...} - Executes the block, and if an non-local exit named tag submitted by the throw, it returns with the value given by the throw.

chop - Removes off the last character of the value of the variable $_. Makes a copy to modify.

chop! - Removes off the last character of the value of the variable $_. Modifies the value itself.

chomp([rs]) - Removes off the line ending from the value of the variable $_.

chomp!([rs]) - Removes off the line ending from the value of the variable $_.

eval(expr[,binding[,filetag[,lineno]]]) - Evaluate expr as a Ruby program.

exec(command...) - Executes command as a subprocess, and never returns.

exit([status]) - Exits immediately with status.

exit([status]) - Exits immediately with status.

fail([error_type,][message][,traceback]) - Raises an exception

fork - Does a fork(2) system call.

format(format...) - Returns a string formatted according to a format like usual printf conventions of the C language.

gets([rs]) - Reads a string from the virtual concatenation of each file listed on the command line or standard input.

global_variables - Returns the list of global variable names defined in the program

gsub(pattern[,replace]) - Searches a string held in the variable $_ for a pattern, and if found, replaces all the occurrence of the pattern with the replace and returns the replaced string.

gsub!(pattern[,replace]) - Searches a string held in the variable $_ for a pattern, and if found, replaces all the occurrence of the pattern with the replace and returns the replaced string.

iterator? - Returns true, if called from within the methods called with the block (the iterators), otherwise false.

lamda - Returns newly created procedure object from the block.

load(file[,priv]) - Loads and evaluates the Ruby program in the file.

local_variables - Returns the list of local variable names defined in the current scope

loop - Loops forever (until terminated explicitly)

open(file[,mode]) - Opens the file, and returns a File object associated with the file.

p(obj) - Prints a human-readable representation of the obj to the stdout.

print(arg1...) - Prints arguments

printf([port,]format, arg...) - Prints arguments formatted according to the format.

proc - Returns newly created procedure object from the block.

putc(c) - Writes a character to the default output.

puts(obj...) - Writes an obj to the default output.

raise([error_type,][message][,traceback]) - Raises an exception

rand(max) - Returns a random integer number greater than or equal to 0 and less than the value of max.

readline([rs]) - Reads a string from the virtual concatenation of each file listed on the command line or standard input.

readlines([rs]) - Reads entire lines from the virtual concatenation of each file listed on the command line or standard input

require(feature) - Demands a library file specified by feature.

select(reads[,writes[,excepts[,timeout]]]) - Calls select(2) system call. Reads, writes, excepts are specified arrays containing instances of the IO class (or its subclass), or nil.

sleep([sec]) - Causes the script to sleep for sec seconds, or forever if no argument is given.

split([sep[,limit]]) - Return an array containing the fields of the string, using the string sep as a separator.

sprintf(format...) - Returns a string formatted according to a format like usual printf conventions of the C language.

srand([seed]) - Sets the random number seed for the rand.

sub(pattern[,replace]) - Searches a string held in the variable $_ for a pattern, and if found, replaces the first occurrence of the pattern with the replace and returns the replaced string.

sub!(pattern[,replace]) - Searches a string held in the variable $_ for a pattern, and if found, replaces the first occurrence of the pattern with the replace and returns the replaced string.

syscall(num, arg...) - Calls the system call specified as the first arguments, passing remaining as arguments to the system call. The arguments must be either a string or an integer.

system(command...) - Perform command in the sub-process, wait for the sub-process to terminate, then return true if it successfully exits, otherwise false.

test(cmd,file[,file]) - Does a file test.

throw(tag[,value]) - Casts an non-local exit to the enclosing catch waiting for tag, or terminates the program if no such catch waiting.

trace_var(variable,command) or trace_var(variable){...} - Sets the hook to the variable, which is called when the value of the variable changed.

trap(signal, command) or trap(signal){...} - Specifies the signal handler for the signal.

untrace_var(variable[,command]) - Deletes the hook associated with the variable