Message to promote available RubyGems update with related gem update command.
Terminates the RubyGems process with the given exit_code
Change the current process’s real and effective user ID to that specified by user. Returns the new user ID. Not available on all platforms.
[Process.uid, Process.euid] #=> [0, 0] Process::UID.change_privilege(31) #=> 31 [Process.uid, Process.euid] #=> [31, 31]
Exchange real and effective user IDs and return the new effective user ID. Not available on all platforms.
[Process.uid, Process.euid] #=> [0, 31] Process::UID.re_exchange #=> 0 [Process.uid, Process.euid] #=> [31, 0]
Returns true
if the real and effective user IDs of a process may be exchanged on the current platform.
Change the current process’s real and effective group ID to that specified by group. Returns the new group ID. Not available on all platforms.
[Process.gid, Process.egid] #=> [0, 0] Process::GID.change_privilege(33) #=> 33 [Process.gid, Process.egid] #=> [33, 33]
Exchange real and effective group IDs and return the new effective group ID. Not available on all platforms.
[Process.gid, Process.egid] #=> [0, 33] Process::GID.re_exchange #=> 0 [Process.gid, Process.egid] #=> [33, 0]
Returns true
if the real and effective group IDs of a process may be exchanged on the current platform.
Check if --yjit-stats
is used.
Discard statistics collected for --yjit-stats
.
Return a hash for statistics generated for the --yjit-stats
command line option. Return nil
when option is not passed or unavailable.
Format and print out counters as a String
. This returns a non-empty content only when --yjit-stats
is enabled.
Calls the given block with each successive grapheme cluster from self
(see Unicode Grapheme Cluster Boundaries); returns self
:
s = "\u0061\u0308-pqr-\u0062\u0308-xyz-\u0063\u0308" # => "ä-pqr-b̈-xyz-c̈" s.each_grapheme_cluster {|gc| print gc, ' ' }
Output:
ä - p q r - b̈ - x y z - c̈
Returns an enumerator if no block is given.
Same as Enumerator#with_index(0)
, i.e. there is no starting offset.
If no block is given, a new Enumerator
is returned that includes the index.
Iterates the given block for each element with an arbitrary object, obj
, and returns obj
If no block is given, returns a new Enumerator
.
to_three = Enumerator.new do |y| 3.times do |x| y << x end end to_three_with_string = to_three.with_object("foo") to_three_with_string.each do |x,string| puts "#{string}: #{x}" end # => foo: 0 # => foo: 1 # => foo: 2
Returns a list of the private instance methods defined in mod. If the optional parameter is false
, the methods of any ancestors are not included.
module Mod def method1() end private :method1 def method2() end end Mod.instance_methods #=> [:method2] Mod.private_instance_methods #=> [:method1]
Returns the Ruby source filename and line number containing the definition of the 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 # line 1 C1 = 1 C2 = 2 end module M # line 6 C3 = 3 end class B < A # line 10 include M C4 = 4 end class A # continuation of A definition C2 = 8 # constant redefinition; warned yet allowed end p B.const_source_location('C4') # => ["test.rb", 12] p B.const_source_location('C3') # => ["test.rb", 7] p B.const_source_location('C1') # => ["test.rb", 2] p B.const_source_location('C3', false) # => nil -- don't lookup in ancestors p A.const_source_location('C2') # => ["test.rb", 16] -- actual (last) definition place p Object.const_source_location('B') # => ["test.rb", 10] -- top-level constant could be looked through Object p Object.const_source_location('A') # => ["test.rb", 1] -- class reopening is NOT considered new definition 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
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. An Array
of Symbols and/or Strings is also accepted.
class SimpleSingleton # Not thread safe private_class_method :new def SimpleSingleton.create(*args, &block) @me = new(*args, &block) if ! @me @me end end