mail us  |  mail this page

products  |  company  |  support  |  downloads  |  isp services  |  contact us

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
   (private/public/protected).
 * Can't make an alias in a nontainted class or module.
 * Can't get meta information (such as method or variable
   lists).
 * 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}
 end
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
end

# more sensibly written as

unless x == y
end
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
 yield
end

# caller 
obj.thing {do something}

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

# caller 
obj.thing {do something}

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

# 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?
  yield(p1,p2)
 else
  p1 + p2
 end
end

# 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
 else
  @attr + p1
 end
end

# 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
	 yield(p1,p2)
  else
   yield(p1)
  end
 else
  p1 + p2
 end
end

# 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.

Copyright © 1994 - 2009 ZyTrax, Inc.
All rights reserved. Legal and Privacy
site by zytrax
Hosted by super.net.sg
web-master at zytrax
Page modified: November 12 2007.

Tech

tech home
audio stuff
web stuff
dom stuff
css stuff
language stuff
regex stuff
rfc stuff
protocol stuff
cable stuff
lan wiring
rs232 wiring
howto stuff
survival stuff
wireless stuff
ascii codes
data rate stuff
telephony stuff
mechanical stuff
pc stuff
electronic stuff
tech links
open guides
RSS Feed Icon RSS Feed

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 Mozilla

web zytrax.com
add page to facebook add page to technorati.com add page to digg.com add page to del.icio.us add page to furl.net add page to stumbleupon add page to reddit.com mail this page feature print this page

Resources

Main Ruby site
Ruby extensions
The Book
Ruby Central.org
ruby-doc.org
Ruby Gargen
RCArchive
rubyxml
RubyGems
Ruby on Rails

very useful

things to know
Ruby PLEAC

our pages

our ruby pages
glossary

printer friendly

Print Page

SPF Record Conformant Domain Logo