Results for: "Data"

Returns a list of the public instance methods defined in mod. If the optional parameter is false, the methods of any ancestors are not included.

Returns a list of the protected instance methods defined in mod. If the optional parameter is false, the methods of any ancestors are not included.

Returns the Ruby source filename and line number containing first definition of constant specified. If the named constant is not found, nil is returned. If the constant is found, but its source location can not be extracted (constant is defined in C code), empty array is returned.

inherit specifies whether to lookup in mod.ancestors (true by default).

# test.rb:
class A
  C1 = 1
end

module M
  C2 = 2
end

class B < A
  include M
  C3 = 3
end

class A # continuation of A definition
end

p B.const_source_location('C3')           # => ["test.rb", 11]
p B.const_source_location('C2')           # => ["test.rb", 6]
p B.const_source_location('C1')           # => ["test.rb", 2]

p B.const_source_location('C2', false)    # => nil  -- don't lookup in ancestors

p Object.const_source_location('B')       # => ["test.rb", 9]
p Object.const_source_location('A')       # => ["test.rb", 1]  -- note it is first entry, not "continuation"

p B.const_source_location('A')            # => ["test.rb", 1]  -- because Object is in ancestors
p M.const_source_location('A')            # => ["test.rb", 1]  -- Object is not ancestor, but additionally checked for modules

p Object.const_source_location('A::C1')   # => ["test.rb", 2]  -- nesting is supported
p Object.const_source_location('String')  # => []  -- constant is defined in C code

Similar to instance_method, searches public method only.

Returns true if the named private method is defined by mod. If inherit is set, the lookup will also search mod’s ancestors. String arguments are converted to symbols.

module A
  def method1()  end
end
class B
  private
  def method2()  end
end
class C < B
  include A
  def method3()  end
end

A.method_defined? :method1                   #=> true
C.private_method_defined? "method1"          #=> false
C.private_method_defined? "method2"          #=> true
C.private_method_defined? "method2", true    #=> true
C.private_method_defined? "method2", false   #=> false
C.method_defined? "method2"                  #=> false

Makes existing class methods private. Often used to hide the default constructor new.

String arguments are converted to symbols.

class SimpleSingleton  # Not thread safe
  private_class_method :new
  def SimpleSingleton.create(*args, &block)
    @me = new(*args, &block) if ! @me
    @me
  end
end
No documentation available

Returns detail information of return value type of method. The information is array.

tobj = WIN32OLE_TYPE.new('Microsoft Excel 9.0 Object Library', 'Workbooks')
method = WIN32OLE_METHOD.new(tobj, 'Add')
p method.return_type_detail # => ["PTR", "USERDEFINED", "Workbook"]

Returns detail information of type of argument.

tobj = WIN32OLE_TYPE.new('Microsoft Excel 9.0 Object Library', 'IWorksheetFunction')
method = WIN32OLE_METHOD.new(tobj, 'SumIf')
param1 = method.params[0]
p param1.ole_type_detail # => ["PTR", "USERDEFINED", "Range"]

Returns detail information of type. The information is array of type.

tobj = WIN32OLE_TYPE.new('DirectX 7 for Visual Basic Type Library', 'D3DCLIPSTATUS')
variable = tobj.variables.find {|variable| variable.name == 'lFlags'}
tdetail  = variable.ole_type_detail
p tdetail # => ["USERDEFINED", "CONST_D3DCLIPSTATUSFLAGS"]

Handle BasicObject instances

No documentation available

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

No documentation available
No documentation available
No documentation available

Starts tracing object allocations from the ObjectSpace extension module.

For example:

require 'objspace'

class C
  include ObjectSpace

  def foo
    trace_object_allocations do
      obj = Object.new
      p "#{allocation_sourcefile(obj)}:#{allocation_sourceline(obj)}"
    end
  end
end

C.new.foo #=> "objtrace.rb:8"

This example has included the ObjectSpace module to make it easier to read, but you can also use the ::trace_object_allocations notation (recommended).

Note that this feature introduces a huge performance decrease and huge memory consumption.

Returns the method identifier for the given object.

class A
  include ObjectSpace

  def foo
    trace_object_allocations do
      obj = Object.new
      p "#{allocation_class_path(obj)}##{allocation_method_id(obj)}"
    end
  end
end

A.new.foo #=> "Class#new"

See ::trace_object_allocations for more information and examples.

Calls CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ON). Starts tracking memory allocations. See also OpenSSL.print_mem_leaks.

This is available only when built with a capable OpenSSL and –enable-debug configure option.

Returns the size of memory allocated by malloc().

Only available if ruby was built with CALC_EXACT_MALLOC_SIZE.

Returns information about the most recent garbage collection.

Returns a list of paths matching glob from the latest gems that can be used by a gem to pick up features from other gems. For example:

Gem.find_latest_files('rdoc/discover').each do |path| load path end

if check_load_path is true (the default), then find_latest_files also searches $LOAD_PATH for files as well as gems.

Unlike find_files, find_latest_files will return only files from the latest version of a gem.

The file name and line number of the caller of the caller of this method.

depth is how many layers up the call stack it should go.

e.g.,

def a; Gem.location_of_caller; end a #=> [“x.rb”, 2] # (it’ll vary depending on file name and line number)

def b; c; end def c; Gem.location_of_caller(2); end b #=> [“x.rb”, 6] # (it’ll vary depending on file name and line number)

Search took: 11ms  ·  Total Results: 1743