Results for: "Pathname"

Returns the source file origin from the given object.

See ::trace_object_allocations for more information and examples.

Returns the original line from source for from the given object.

See ::trace_object_allocations for more information and examples.

Return consuming memory size of obj in bytes.

Note that the return size is incomplete. You need to deal with this information as only a HINT. Especially, the size of T_DATA may not be correct.

This method is only expected to work with C Ruby.

From Ruby 2.2, memsize_of(obj) returns a memory size includes sizeof(RVALUE).

Adds aProc as a finalizer, to be called after obj was destroyed. The object ID of the obj will be passed as an argument to aProc. If aProc is a lambda or method, make sure it can be called with a single argument.

The return value is an array [0, aProc].

The two recommended patterns are to either create the finaliser proc in a non-instance method where it can safely capture the needed state, or to use a custom callable object that stores the needed state explicitly as instance variables.

class Foo
  def initialize(data_needed_for_finalization)
    ObjectSpace.define_finalizer(self, self.class.create_finalizer(data_needed_for_finalization))
  end

  def self.create_finalizer(data_needed_for_finalization)
    proc {
      puts "finalizing #{data_needed_for_finalization}"
    }
  end
end

class Bar
 class Remover
    def initialize(data_needed_for_finalization)
      @data_needed_for_finalization = data_needed_for_finalization
    end

    def call(id)
      puts "finalizing #{@data_needed_for_finalization}"
    end
  end

  def initialize(data_needed_for_finalization)
    ObjectSpace.define_finalizer(self, Remover.new(data_needed_for_finalization))
  end
end

Note that if your finalizer references the object to be finalized it will never be run on GC, although it will still be run at exit. You will get a warning if you capture the object to be finalized as the receiver of the finalizer.

class CapturesSelf
  def initialize(name)
    ObjectSpace.define_finalizer(self, proc {
      # this finalizer will only be run on exit
      puts "finalizing #{name}"
    })
  end
end

Also note that finalization can be unpredictable and is never guaranteed to be run except on exit.

Removes all finalizers for obj.

Constant time memory comparison. Inputs are hashed using SHA-256 to mask the length of the secret. Returns true if the strings are identical, false otherwise.

Parse a file at filename. Returns the Psych::Nodes::Document.

Raises a Psych::SyntaxError when a YAML syntax error is detected.

Dump a list of objects as separate documents to a document stream.

Example:

Psych.dump_stream("foo\n  ", {}) # => "--- ! \"foo\\n  \"\n--- {}\n"

Load multiple documents given in yaml. Returns the parsed documents as a list. If a block is given, each document will be converted to Ruby and passed to the block during parsing

Example:

Psych.load_stream("--- foo\n...\n--- bar\n...") # => ['foo', 'bar']

list = []
Psych.load_stream("--- foo\n...\n--- bar\n...") do |ruby|
  list << ruby
end
list # => ['foo', 'bar']

Returns the version of libyaml being used

Returns information for heaps in the GC.

If the first optional argument, heap_name, is passed in and not nil, it returns a Hash containing information about the particular heap. Otherwise, it will return a Hash with heap names as keys and a Hash containing information about the heap as values.

If the second optional argument, hash_or_key, is given as Hash, it will be overwritten and returned. This is intended to avoid the probe effect.

If both optional arguments are passed in and the second optional argument is a symbol, it will return a Numeric of the value for the particular heap.

On CRuby, heap_name is of the type Integer but may be of type String on other implementations.

The contents of the hash are implementation specific and may change in the future without notice.

If the optional argument, hash, is given, it is overwritten and returned.

This method is only expected to work on CRuby.

The hash includes the following keys about the internal information in the GC:

slot_size

The slot size of the heap in bytes.

heap_allocatable_pages

The number of pages that can be allocated without triggering a new garbage collection cycle.

heap_eden_pages

The number of pages in the eden heap.

heap_eden_slots

The total number of slots in all of the pages in the eden heap.

heap_tomb_pages

The number of pages in the tomb heap. The tomb heap only contains pages that do not have any live objects.

heap_tomb_slots

The total number of slots in all of the pages in the tomb heap.

total_allocated_pages

The total number of pages that have been allocated in the heap.

total_freed_pages

The total number of pages that have been freed and released back to the system in the heap.

force_major_gc_count

The number of times major garbage collection cycles this heap has forced to start due to running out of free slots.

force_incremental_marking_finish_count

The number of times this heap has forced incremental marking to complete due to running out of pooled slots.

Return measured GC total time in nano seconds.

Try to activate a gem containing path. Returns true if activation succeeded or wasn’t needed because it was already activated. Returns false if it can’t find the path in a gem.

The mode needed to read a file as straight binary.

Loads YAML, preferring Psych

Safely read a file in binary mode on all platforms.

Safely write a file in binary mode on all platforms.

No documentation available

Is this a windows platform?

Is this a java platform?

Is this platform Solaris?

Is this platform FreeBSD

Finds the user’s home directory.

The home directory for the user.

The path to standard location of the user’s configuration directory.

Search took: 4ms  ·  Total Results: 2413