Appends str
to the string being scanned. This method does not affect scan pointer.
s = StringScanner.new("Fri Dec 12 1975 14:39") s.scan(/Fri /) s << " +1000 GMT" s.string # -> "Fri Dec 12 1975 14:39 +1000 GMT" s.scan(/Dec/) # -> "Dec"
Returns running OLE Automation object or WIN32OLE
object from moniker. 1st argument should be OLE program id or class id or moniker.
WIN32OLE.connect('Excel.Application') # => WIN32OLE object which represents running Excel.
Returns the type library version.
tlib = WIN32OLE_TYPELIB.new('Microsoft Excel 9.0 Object Library') puts tlib.version #-> "1.3"
Returns revision information for the erb.rb module.
Task
description for the clobber rdoc task or its renamed equivalent
Task
description for the rdoc task or its renamed equivalent
Task
description for the rerdoc task or its renamed description
Establishes proc on thr as the handler for tracing, or disables tracing if the parameter is nil
.
Adds proc as a handler for tracing.
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
Note that for c-call
and c-return
events, the binding returned is the binding of the nearest Ruby method calling the C method, since C methods themselves do not have bindings.
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.
Iterates over strongly connected component in the subgraph reachable from node.
Return value is unspecified.
each_strongly_connected_component_from
doesn’t call tsort_each_node
.
class G include TSort def initialize(g) @g = g end def tsort_each_child(n, &b) @g[n].each(&b) end def tsort_each_node(&b) @g.each_key(&b) end end graph = G.new({1=>[2, 3], 2=>[4], 3=>[2, 4], 4=>[]}) graph.each_strongly_connected_component_from(2) {|scc| p scc } #=> [4] # [2] graph = G.new({1=>[2], 2=>[3, 4], 3=>[2], 4=>[]}) graph.each_strongly_connected_component_from(2) {|scc| p scc } #=> [4] # [2, 3]
Iterates over strongly connected components in a graph. The graph is represented by node and each_child.
node is the first node. each_child should have call
method which takes a node argument and yields for each child node.
Return value is unspecified.
TSort.each_strongly_connected_component_from is a class method and it doesn’t need a class to represent a graph which includes TSort
.
graph = {1=>[2], 2=>[3, 4], 3=>[2], 4=>[]} each_child = lambda {|n, &b| graph[n].each(&b) } TSort.each_strongly_connected_component_from(1, each_child) {|scc| p scc } #=> [4] # [2, 3] # [1]
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',....]