Verify internal consistency.
This method is implementation specific. Now this method checks generational consistency if RGenGC is supported.
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.
If the optional argument, hash, is given, it is overwritten and returned. This is intended to avoid probe effect.
Verify compaction reference consistency.
This method is implementation specific. During compaction, objects that were moved are replaced with T_MOVED objects. No object should have a reference to a T_MOVED object after compaction.
This function expands the heap to ensure room to move all objects, compacts the heap to make sure everything moves, updates all references, then performs a full GC. If any object contains a reference to a T_MOVED object, that object should be pushed on the mark stack, and will make a SEGV.
Shortcut for defining multiple delegator methods, but with no provision for using a different name. The following two code samples have the same effect:
def_delegators :@records, :size, :<<, :map def_delegator :@records, :size def_delegator :@records, :<< def_delegator :@records, :map
Define method
as delegator instance method with an optional alias name ali
. Method
calls to ali
will be delegated to accessor.method
. accessor
should be a method name, instance variable name, or constant name. Use the full path to the constant if providing the constant name. Returns the name of the method defined.
class MyQueue CONST = 1 extend Forwardable attr_reader :queue def initialize @queue = [] end def_delegator :@queue, :push, :mypush def_delegator 'MyQueue::CONST', :to_i end q = MyQueue.new q.mypush 42 q.queue #=> [42] q.push 23 #=> NoMethodError q.to_i #=> 1
Shortcut for defining multiple delegator methods, but with no provision for using a different name. The following two code samples have the same effect:
def_delegators :@records, :size, :<<, :map def_delegator :@records, :size def_delegator :@records, :<< def_delegator :@records, :map
Defines a method method which delegates to accessor (i.e. it calls the method of the same name in accessor). If new_name is provided, it is used as the name for the delegate method. Returns the name of the method defined.
Returns whether or not the struct of type type
contains member
. If it does not, or the struct type can’t be found, then false is returned. You may optionally specify additional headers
in which to look for the struct (in addition to the common header files).
If found, a macro is passed as a preprocessor constant to the compiler using the type name and the member name, in uppercase, prepended with HAVE_
.
For example, if have_struct_member('struct foo', 'bar')
returned true, then the HAVE_STRUCT_FOO_BAR
preprocessor macro would be passed to the compiler.
HAVE_ST_BAR
is also defined for backward compatibility.
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)
Returns the latest release-version specification for the gem name
.
Returns the latest release version of RubyGems.
Returns the version of the latest release-version of gem name
Returns the value of Gem.source_date_epoch_string
, as a Time
object.
This is used throughout RubyGems for enabling reproducible builds.
Path to specification files of default gems.
Deduce Ruby’s –program-prefix and –program-suffix from its install name
Default options for gem commands for Ruby packagers.
The options here should be structured as an array of string “gem” command names as keys and a string of the default options as values.
Example:
def self.operating_system_defaults
{ 'install' => '--no-rdoc --no-ri --env-shebang', 'update' => '--no-rdoc --no-ri --env-shebang' }
end
Generates a private and public key unless a private key already exists. If this DH
instance was generated from public DH parameters (e.g. by encoding the result of DH#public_key
), then this method needs to be called first in order to generate the per-session keys before performing the actual key exchange.
Deprecated in version 3.0. This method is incompatible with OpenSSL
3.0.0 or later.
See also OpenSSL::PKey.generate_key
.
Example:
# DEPRECATED USAGE: This will not work on OpenSSL 3.0 or later dh0 = OpenSSL::PKey::DH.new(2048) dh = dh0.public_key # #public_key only copies the DH parameters (contrary to the name) dh.generate_key! puts dh.private? # => true puts dh0.pub_key == dh.pub_key #=> false # With OpenSSL::PKey.generate_key dh0 = OpenSSL::PKey::DH.new(2048) dh = OpenSSL::PKey.generate_key(dh0) puts dh0.pub_key == dh.pub_key #=> false
See the OpenSSL
documentation for EC_KEY_get0_private_key()
See the OpenSSL
documentation for EC_KEY_set_private_key()
Generates a new random private and public key.
See also the OpenSSL
documentation for EC_KEY_generate_key()
ec = OpenSSL::PKey::EC.new("prime256v1") p ec.private_key # => nil ec.generate_key! p ec.private_key # => #<OpenSSL::BN XXXXXX>
Returns whether this EC
instance has a private key. The private key (BN
) can be retrieved with EC#private_key
.
Generates a new random private and public key.
See also the OpenSSL
documentation for EC_KEY_generate_key()
ec = OpenSSL::PKey::EC.new("prime256v1") p ec.private_key # => nil ec.generate_key! p ec.private_key # => #<OpenSSL::BN XXXXXX>
Encrypt string
with the private key. padding
defaults to PKCS1_PADDING
, which is known to be insecure but is kept for backwards compatibility. The encrypted string output can be decrypted using public_decrypt
.
Deprecated in version 3.0. Consider using PKey::PKey#sign_raw
and PKey::PKey#verify_raw
, and PKey::PKey#verify_recover
instead.