pretty_inspect

pretty_inspect() Instance Public methods returns a pretty printed object as a string.

p

p(obj) â objp(obj1, obj2, ...) â [obj, ...]p() â nil Instance Public methods For each object, directly writes obj.inspect followed by a newline to the program's standard output. S = Struct.new(:name, :state) s = S['dave', 'TX'] p s produces: #<S name="dave", state="TX">

loop

loop { block }loop â an_enumerator Instance Public methods Repeatedly executes the block. If no block is given, an enumerator is returned instead. loop do print "Input: " line = gets break if !line or line =~ /^qQ/ # ... end StopIteration raised in the block breaks the loop.

local_variables

local_variables â array Instance Public methods Returns the names of the current local variables. fred = 1 for i in 1..10 # ... end local_variables #=> [:fred, :i]

load

load(filename, wrap=false) â true Instance Public methods Loads and executes the Ruby program in the file filename. If the filename does not resolve to an absolute path, the file is searched for in the library directories listed in $:. If the optional wrap parameter is true, the loaded script will be executed under an anonymous module, protecting the calling program's global namespace. In no circumstance will any local variables in the loaded file be propagated to the loading en

lambda

lambda { |...| block } â a_proc Instance Public methods Equivalent to Proc.new, except the resulting Proc objects check the number of parameters passed when called.

iterator?

iterator? â 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"

gsub

gsub(pattern, replacement) â stringgsub(pattern) {|...| block } â string Instance Public methods Equivalent to $_.gsub..., except that $_ receives the modified result. Available only when -p/-n command line option specified.

global_variables

global_variables â array Instance Public methods Returns an array of the names of global variables. global_variables.grep /std/ #=> [:$stdin, :$stdout, :$stderr]

gets

gets(sep=$/) â string or nilgets(limit) â string or nilgets(sep,limit) â string or nil Instance Public methods Returns (and assigns to $_) the next line from the list of files in ARGV (or $*), or from standard input if no files are present on the command line. Returns nil at end of file. The optional argument specifies the record separator. The separator is included with the contents of each record. A separator of nil reads the entire contents, and a zero-length separator r