Temporarily turn off warnings. Intended for tests only.
Remove any non-printable characters and make the text suitable for printing.
Displays an error statement
to the error output location. Asks a question
if given.
Displays a warning statement
to the warning output location. Asks a question
if given.
Invokes system, but silences all output.
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]
Set
the effective user ID, and if possible, the saved user ID of the process to the given user. Returns the new effective user ID. Not available on all platforms.
[Process.uid, Process.euid] #=> [0, 0] Process::UID.grant_privilege(31) #=> 31 [Process.uid, Process.euid] #=> [0, 31]
Returns true
if the real and effective user IDs of a process may be exchanged on the current platform.
Returns true
if the current platform has saved user ID functionality.
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]
Set
the effective group ID, and if possible, the saved group ID of the process to the given group. Returns the new effective group ID. Not available on all platforms.
[Process.gid, Process.egid] #=> [0, 0] Process::GID.grant_privilege(31) #=> 33 [Process.gid, Process.egid] #=> [0, 33]
Returns true
if the real and effective group IDs of a process may be exchanged on the current platform.
Returns true
if the current platform has saved group ID functionality.
Check if --yjit-stats
is used.
Discard existing compiled code to reclaim memory and allow for recompilations in the future.
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
DO NOT USE THIS DIRECTLY.
Hook method to return whether the obj can respond to id method or not.
When the method name parameter is given as a string, the string is converted to a symbol.
See respond_to?
, and the example of BasicObject
.
Returns true
if the stream will be closed on exec, false
otherwise:
f = File.open('t.txt') f.close_on_exec? # => true f.close_on_exec = false f.close_on_exec? # => false f.close
Sets a close-on-exec flag.
f = File.open(File::NULL) f.close_on_exec = true system("cat", "/proc/self/fd/#{f.fileno}") # cat: /proc/self/fd/3: No such file or directory f.closed? #=> false
Ruby sets close-on-exec flags of all file descriptors by default since Ruby 2.0.0. So you don’t need to set by yourself. Also, unsetting a close-on-exec flag can cause file descriptor leak if another thread use fork() and exec() (via system() method for example). If you really needs file descriptor inheritance to child process, use spawn()‘s argument such as fd=>fd.
Makes the set compare its elements by their identity and returns self. This method may not be supported by all subclasses of Set
.
Returns true if the set will compare its elements by their identity. Also see Set#compare_by_identity
.