mail us  |  mail this page

contact us
training  | 
tech stuff  | 

Tech Stuff - Ruby Glossary S - Z

The beginning of our point and click glossary to ruby - we'll see how it goes. If the item below has got a link read it - otherwise put up with our definition. You have been warned!

Glossary Navigation

Select from the range below:

Symbols ?, #, ::, etc. | a - d | e - l | m - r | s - z

term parent description
$SAFE Core API Global Safety Level (from Pickaxe):
 $SAFE >= 1
 * The environment variables RUBYLIB and RUBYOPT
   are not processed,
   and the current directory is not added to the path.
 * The command-line options -e, -i, -I, -r, -s, -S, 
   and -x are not allowed.
 * Can't start processes from $PATH if any directory
   in it is world-writable.
 * Can't manipulate or chroot to a directory
   whose name is a tainted string.
 * Can't glob tainted strings.
 * Can't eval tainted strings.
 * Can't load or require a file whose name is a
   tainted string.
 * Can't manipulate or query the status of a file or
   pipe whose name is a tainted string.
 * Can't execute a system command or exec a program
   from a tainted string.
 * Can't pass trap a tainted string.

$SAFE >= 2
 * Can't change, make, or remove directories, or use chroot.
 * Can't load a file from a world-writable directory.
 * Can't load a file from a tainted filename starting with ~.
 * Can't use File#chmod, File#chown, File#lstat, 
   File.stat , File#truncate , File.umask , File#flock,
   IO#ioctl , IO#stat , Kernel#fork , Kernel#syscall ,
   Kernel#trap . Process::setpgid , Process::setsid ,
   Process::setpriority , or Process::egid= .
 * Can't handle signals using trap.

$SAFE >= 3
 * All objects are created tainted.
 * Can't untaint objects.

$SAFE >= 4
 * Can't modify a nontainted array, hash, or string.
 * Can't modify a global variable.
 * Can't access instance variables of nontainted objects.
 * Can't change an environment variable.
 * Can't close or reopen nontainted files.
 * Can't freeze nontainted objects.
 * Can't change visibility of methods
 * Can't make an alias in a nontainted class or module.
 * Can't get meta information (such as method or variable
 * Can't define, redefine, remove, or undef a method in
   a nontainted class or module.
 * Can't modify Object.
 * Can't remove instance variables or constants from
   non-tainted objects.
 * Can't manipulate threads, terminate a thread other
   than the current, or set abort_on_exception.
 * Can't have thread local variables.
 * Can't raise an exception in a thread with a lower
   $SAFE value.
 * Can't move threads between ThreadGroups.
 * Can't invoke exit, exit!, or abort.
 * Can load only wrapped files, and can't include modules
   in nontainted classes and modules.
 * Can't convert symbol identifiers to object references.
 * Can't write to files or pipes.
 * Can't use autoload.
 * Can't taint objects.
scope Core API scope variable names
$ - global
@ - instance
@@ - class
String Core API->String String Object. unpack method.
strings Core API multiple definitions
# double quotes - allows escaping
"variable is substitued #{myvar}"
"newline is substituted \n"
# single quotes - char escaping only
' variable is not substituted #{myvar}'
'escapes the \' single quote'
# % form %q(single quote) or $Q (double quote) 
# delimiters may be () [] {} <>
%Q("this is a string including double quotes)
# % x execute - sent to OS
%x[ps ax|more]
# %r - regex
# %w array 
myarray = %w[one two three]
super Core API invokes the parent class hierarchy with same parameters
# called with no params - 
# scans hierarchy looking for mmethod executes 
# then runs {local stuff}
 def mmethod
 super + {local stuff}
times Core API Applies to integer and iterates from zero to integer value -1
# NOTE: integer 0 iterates zero times
3.times {|i| print i} # => 0 1 2
unless Core API Inverted form of if - anywhere you can use if you can use unless if the code reads more sensibly:
if x != y

# more sensibly written as

unless x == y
unpack String Method of String takes the following parameters (incomplete list - we add as we use 'em):
m  takes a base64 encoded string returns a string
value? Hash Alias for has_value?
yield Core API Executes the supplied code block (remember: all methods may take an optional block argument):
# simple form
def thing

# caller 
obj.thing {do something}

# test for block
def thing
 if block_given? 
 	puts "no block given"

# caller 
obj.thing {do something}

# inside an iterator
def thing
 @myarray.each {|x| yield x}

# caller
obj.thing {|y| do something to y}
# block applied to each element of the array

# passing arguments to yield
def thing(p1,p2)
 if block_given?
  p1 + p2

# caller
obj.thing(2,3) {|x,y| x*x + y*y } # => 13
obj.thing(2,3) # => 5

# internal arguments to yield
@attr = 5
def thing(p1)
 if block_given?
  yield(@attr,p1) # uses instance variable
  @attr + p1

# caller
obj.thing(2) {|x,y| x*x + y*y } # => 29
obj.thing(2) # => 7

# passing variable number of arguments to yield
# block made visible using & which creates Proc object
def thing(p1,p2,&bb)
 if block_given?
  if bb.arity == 2
  p1 + p2

# caller
obj.thing(2) {|x| x*x } # => 4
obj.thing(2,3) {|x,y| x*x + y*y } # => 13
obj.thing(2,3) # => 5

Glossary Navigation

Select from the range below:

Symbols ?, #, ::, etc. | a - d | e - l | m - r | s - z

Problems, comments, suggestions, corrections (including broken links) or something to add? Please take the time from a busy life to 'mail us' (at top of screen), the webmaster (below) or info-support at zytrax. You will have a warm inner glow for the rest of the day.

Tech Stuff

If you are happy it's OK - but your browser is giving a less than optimal experience on our site. You could, at no charge, upgrade to a W3C standards compliant browser such as Firefox




share page via facebook tweet this page


email us Send to a friend feature print this page Decrease font size Increase font size Display full width page


Main Ruby site
The Book
Ruby on Rails

Useful Stuff


Our Pages

our ruby pages


CSS Technology SPF Record Conformant Domain
Copyright © 1994 - 2017 ZyTrax, Inc.
All rights reserved. Legal and Privacy
site by zytrax
Hosted by
web-master at zytrax
Page modified: October 21 2015.