Return true
if the named file exists.
file_name can be an IO
object.
“file exists” means that stat() or fstat() system call is successful.
Returns true
if the named file is readable by the effective user and group id of this process. See eaccess(3).
Note that some OS-level security features may cause this to return true even though the file is not readable by the effective user/group.
Returns true
if the named file has the sticky bit set.
file_name can be an IO
object.
Initiates garbage collection, even if manually disabled.
The full_mark
keyword argument determines whether or not to perform a major garbage collection cycle. When set to true
, a major garbage collection cycle is ran, meaning all objects are marked. When set to false
, a minor garbage collection cycle is ran, meaning only young objects are marked.
The immediate_mark
keyword argument determines whether or not to perform incremental marking. When set to true
, marking is completed during the call to this method. When set to false
, marking is performed in steps that is interleaved with future Ruby code execution, so marking might not be completed during this method call. Note that if full_mark
is false
then marking will always be immediate, regardless of the value of immediate_mark
.
The immedate_sweep
keyword argument determines whether or not to defer sweeping (using lazy sweep). When set to true
, sweeping is performed in steps that is interleaved with future Ruby code execution, so sweeping might not be completed during this method call. When set to false
, sweeping is completed during the call to this method.
Note: These keyword arguments are implementation and version dependent. They are not guaranteed to be future-compatible, and may be ignored if the underlying implementation does not support them.
Returns a Hash
containing information about the GC.
The contents of the hash are implementation specific and may change in the future without notice.
The hash includes information about internal statistics about GC such as:
The total number of garbage collections ran since application start (count includes both minor and major garbage collections)
The total time spent in garbage collections (in milliseconds)
The total number of :heap_eden_pages
+ :heap_tomb_pages
The number of pages that can fit into the buffer that holds references to all pages
The total number of pages the application could allocate without additional GC
The total number of slots in all :heap_allocated_pages
The total number of slots which contain live objects
The total number of slots which do not contain live objects
The total number of slots with pending finalizers to be run
The total number of objects marked in the last GC
The total number of pages which contain at least one live slot
The total number of pages which do not contain any live slots
The cumulative number of pages allocated since application start
The cumulative number of pages freed since application start
The cumulative number of objects allocated since application start
The cumulative number of objects freed since application start
Amount of memory allocated on the heap for objects. Decreased by any GC
When :malloc_increase_bytes
crosses this limit, GC is triggered
The total number of minor garbage collections run since process start
The total number of major garbage collections run since process start
The total number of compactions run since process start
The total number of times the read barrier was triggered during compaction
The total number of objects compaction has moved
The total number of objects without write barriers
When :remembered_wb_unprotected_objects
crosses this limit, major GC is triggered
Number of live, old objects which have survived at least 3 garbage collections
When :old_objects
crosses this limit, major GC is triggered
Amount of memory allocated on the heap for objects. Decreased by major GC
When :old_malloc_increase_bytes
crosses this limit, major GC is triggered
If the optional argument, hash, is given, it is overwritten and returned. This is intended to avoid probe effect.
This method is only expected to work on CRuby.
Given a set of strings, calculate the set of unambiguous abbreviations for those strings, and return a hash where the keys are all the possible abbreviations and the values are the full strings.
Thus, given words
is “car” and “cone”, the keys pointing to “car” would be “ca” and “car”, while those pointing to “cone” would be “co”, “con”, and “cone”.
require 'abbrev' Abbrev.abbrev(%w{ car cone }) #=> {"ca"=>"car", "con"=>"cone", "co"=>"cone", "car"=>"car", "cone"=>"cone"}
The optional pattern
parameter is a pattern or a string. Only input strings that match the pattern or start with the string are included in the output hash.
Abbrev.abbrev(%w{car box cone crab}, /b/) #=> {"box"=>"box", "bo"=>"box", "b"=>"box", "crab" => "crab"} Abbrev.abbrev(%w{car box cone}, 'ca') #=> {"car"=>"car", "ca"=>"car"}
Given a set of strings, calculate the set of unambiguous abbreviations for those strings, and return a hash where the keys are all the possible abbreviations and the values are the full strings.
Thus, given words
is “car” and “cone”, the keys pointing to “car” would be “ca” and “car”, while those pointing to “cone” would be “co”, “con”, and “cone”.
require 'abbrev' Abbrev.abbrev(%w{ car cone }) #=> {"ca"=>"car", "con"=>"cone", "co"=>"cone", "car"=>"car", "cone"=>"cone"}
The optional pattern
parameter is a pattern or a string. Only input strings that match the pattern or start with the string are included in the output hash.
Abbrev.abbrev(%w{car box cone crab}, /b/) #=> {"box"=>"box", "bo"=>"box", "b"=>"box", "crab" => "crab"} Abbrev.abbrev(%w{car box cone}, 'ca') #=> {"car"=>"car", "ca"=>"car"}
Returns the time used to execute the given block as a Benchmark::Tms
object. Takes label
option.
require 'benchmark' n = 1000000 time = Benchmark.measure do n.times { a = "1" } end puts time
Generates:
0.220000 0.000000 0.220000 ( 0.227313)
Returns the elapsed real time used to execute the given block.
Returns the time used to execute the given block as a Benchmark::Tms
object. Takes label
option.
require 'benchmark' n = 1000000 time = Benchmark.measure do n.times { a = "1" } end puts time
Generates:
0.220000 0.000000 0.220000 ( 0.227313)
Returns the elapsed real time used to execute the given block.
Top level install helper method. Allows you to install gems interactively:
% irb >> Gem.install "minitest" Fetching: minitest-5.14.0.gem (100%) => [#<Gem::Specification:0x1013b4528 @name="minitest", ...>]
Get the default RubyGems API host. This is normally https://rubygems.org
.
Set
the default RubyGems API host.
Set
array of platforms this RubyGems supports (primarily for testing).
Array
of platforms this RubyGems supports.
The directory prefix this RubyGems was installed at. If your prefix is in a standard location (ie, rubygems is installed where you’d expect it to be), then prefix returns nil.
Returns the currently set formatter. By default, it is set to DidYouMean::Formatter
.
Updates the primary formatter used to format the suggestions.
Is uri
the URI
for the current local server?
Get the thread of the primary server.
This returns nil if there is no primary server. See primary_server
.
Get the thread of the primary server.
This returns nil if there is no primary server. See primary_server
.