catch

catch([arg]) {|tag| block } â obj Instance Public methods catch executes its block. If a throw is executed, Ruby searches up its stack for a catch block with a tag corresponding to the throw's tag. If found, that block is terminated, and catch returns the value given to throw. If throw is not called, the block terminates normally, and the value of catch is the value of the last expression evaluated. catch expressions may be nested, and the throw call need not be in lexical scope.

caller_locations

caller_locations(start=1, length=nil) â array or nilcaller_locations(range) â array or nil Instance Public methods Returns the current execution stackâan array containing backtrace location objects. See Thread::Backtrace::Location for more information. The optional start parameter determines the number of initial stack entries to omit from the top of the stack. A second optional length parameter can be used to limit how many entries are returned from the stack.

caller

caller(start=1, length=nil) â array or nilcaller(range) â array or nil Instance Public methods Returns the current execution stackâan array containing strings in the form file:line or file:line: in `method'. The optional start parameter determines the number of initial stack entries to omit from the top of the stack. A second optional length parameter can be used to limit how many entries are returned from the stack. Returns nil if start is greater than the size of

callcc

callcc {|cont| block } â obj Instance Public methods Generates a Continuation object, which it passes to the associated block. You need to require 'continuation' before using this method. Performing a cont.call will cause the callcc to return (as will falling through the end of the block). The value returned by the callcc is the value of the block, or the value passed to cont.call. See class Continuation for more details. Also see #throw for an alternative mechanism for unwindi

block_given?

block_given? â true or false Instance Public methods Returns true if yield would execute a block in the current context. The iterator? form is mildly deprecated. def try if block_given? yield else "no block" end end try #=> "no block" try { "hello" } #=> "hello" try do "hello" end #=> "hello"

binding

binding â a_binding Instance Public methods Returns a Binding object, describing the variable and method bindings at the point of call. This object can be used when calling eval to execute the evaluated command in this environment. See also the description of class Binding. def get_binding(param) return binding end b = get_binding("hello") eval("param", b) #=> "hello"

autoload?

autoload?(name) â String or nil Instance Public methods Returns filename to be loaded if name is registered as autoload. autoload(:B, "b") autoload?(:B) #=> "b"

autoload

autoload(module, filename) â nil Instance Public methods Registers filename to be loaded (using Kernel::require) the first time that module (which may be a String or a symbol) is accessed. autoload(:MyModule, "/usr/local/lib/modules/my_module.rb")

at_exit

at_exit { block } â proc Instance Public methods Converts block to a Proc object (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. def do_at_exit(str1) at_exit { print str1 } end at_exit { puts "cruel world" } do_at_exit("goodbye ") exit produces: goodbye cruel world

abort

abortKernel::abort([msg])Process::abort([msg]) Instance Public methods Terminate execution immediately, effectively by calling Kernel.exit(false). If msg is given, it is written to STDERR prior to terminating.