Establishes proc as the handler for tracing, or disables tracing if the parameter is nil
.
Note: this method is obsolete, please use TracePoint
instead.
proc takes up to six parameters:
an event name
a filename
a line number
an object id
a binding
the name of a class
proc is invoked whenever an event occurs.
Events are:
c-call
call a C-language routine
c-return
return from a C-language routine
call
call a Ruby method
class
start a class or module definition
end
finish a class or module definition
line
execute code on a new line
raise
raise an exception
return
return from a Ruby method
Tracing is disabled within the context of proc.
class Test def test a = 1 b = 2 end end set_trace_func proc { |event, file, line, id, binding, classname| printf "%8s %s:%-2d %10s %8s\n", event, file, line, id, classname } t = Test.new t.test line prog.rb:11 false c-call prog.rb:11 new Class c-call prog.rb:11 initialize Object c-return prog.rb:11 initialize Object c-return prog.rb:11 new Class line prog.rb:12 false call prog.rb:2 test Test line prog.rb:3 test Test line prog.rb:4 test Test return prog.rb:4 test Test
Returns the class for the given object
.
class A def foo ObjectSpace::trace_object_allocations do obj = Object.new p "#{ObjectSpace::allocation_class_path(obj)}" end end end A.new.foo #=> "Class"
See ::trace_object_allocations
for more information and examples.
Returns the BubbleBabble encoded hash value of a given string.
Returns an integer representing the permission bits of stat. The meaning of the bits is platform dependent; on Unix systems, see stat(2)
.
File.chmod(0644, "testfile") #=> 1 s = File.stat("testfile") sprintf("%o", s.mode) #=> "100644"
Returns the resulting hash value in a Bubblebabble encoded form.
Returns true if the given year is a leap year of the proleptic Julian calendar.
Date.julian_leap?(1900) #=> true Date.julian_leap?(1901) #=> false
Returns the array of WIN32OLE_METHOD
object. The element is OLE method of WIN32OLE
object.
excel = WIN32OLE.new('Excel.Application') methods = excel.ole_methods
Returns WIN32OLE_METHOD
object corresponding with method specified by 1st argument.
excel = WIN32OLE.new('Excel.Application') method = excel.ole_method_help('Quit')
Returns array of WIN32OLE_METHOD
objects which represent OLE method defined in OLE type library.
tobj = WIN32OLE_TYPE.new('Microsoft Excel 9.0 Object Library', 'Worksheet') methods = tobj.ole_methods.collect{|m| m.name } # => ['Activate', 'Copy', 'Delete',....]
Returns the file extension appended to the names of modified files under in-place edit mode. This value can be set using ARGF.inplace_mode=
or passing the -i
switch to the Ruby binary.
Sets the filename extension for in-place editing mode to the given String
. Each file being edited has this value appended to its filename. The modified file is saved under this new name.
For example:
$ ruby argf.rb file.txt ARGF.inplace_mode = '.bak' ARGF.each_line do |line| print line.sub("foo","bar") end
Each line of file.txt has the first occurrence of “foo” replaced with “bar”, then the new line is written out to file.txt.bak.
Turns FIPS mode on or off. Turning on FIPS mode will obviously only have an effect for FIPS-capable installations of the OpenSSL
library. Trying to do so otherwise will result in an error.
OpenSSL.fips_mode = true # turn FIPS mode on OpenSSL.fips_mode = false # and off again
Removes a file path
. This method ignores StandardError
if force
is true.
Removes a file path
. This method ignores StandardError
if force
is true.
Takes a hash as its argument. The key is a symbol or an array of symbols. These symbols correspond to method names. The value is the accessor to which the methods will be delegated.
creates a stub Makefile.