Results for: "remove_const"

Check if --yjit-stats is used.

Return a hash for statistics generated for the --yjit-stats command line option. Return nil when option is not passed or unavailable. If a symbol argument is provided, return only the value for the named stat. If any other type is provided, raises TypeError.

Discard existing compiled code to reclaim memory and allow for recompilations in the future.

Assert that any future ZJIT compilation will return a function pointer

END {}

When the content of a string node is split across multiple lines, the parser gem creates individual string nodes for each line the content is part of.

END {}

No documentation available
No documentation available
No documentation available

Defines a public singleton method in the receiver. The method parameter can be a Proc, a Method or an UnboundMethod object. If a block is specified, it is used as the method body. If a block or a method has parameters, they’re used as method parameters.

class A
  class << self
    def class_name
      to_s
    end
  end
end
A.define_singleton_method(:who_am_i) do
  "I am: #{class_name}"
end
A.who_am_i   # ==> "I am: A"

guy = "Bob"
guy.define_singleton_method(:hello) { "#{self}: Hello there!" }
guy.hello    #=>  "Bob: Hello there!"

chris = "Chris"
chris.define_singleton_method(:greet) {|greeting| "#{greeting}, I'm Chris!" }
chris.greet("Hi") #=> "Hi, I'm Chris!"

Yields while console input events are queued.

This method is Windows only.

You must require ‘io/console’ to use this method.

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.

Returns whether Happy Eyeballs Version 2 (RFC 8305), which is provided starting from Ruby 3.4 when using TCPSocket.new and Socket.tcp, is enabled or disabled.

If true, it is enabled for TCPSocket.new and Socket.tcp. (Note: Happy Eyeballs Version 2 is not provided when using TCPSocket.new on Windows.)

If false, Happy Eyeballs Version 2 is disabled.

For details on Happy Eyeballs Version 2, see Socket.tcp_fast_fallback=.

Enable or disable Happy Eyeballs Version 2 (RFC 8305) globally, which is provided starting from Ruby 3.4 when using TCPSocket.new and Socket.tcp.

When set to true, the feature is enabled for both ‘TCPSocket.new` and `Socket.tcp`. (Note: This feature is not available when using TCPSocket.new on Windows.)

When set to false, the behavior reverts to that of Ruby 3.3 or earlier.

The default value is true if no value is explicitly set by calling this method. However, when the environment variable RUBY_TCP_NO_FAST_FALLBACK=1 is set, the default is false.

To control the setting on a per-method basis, use the fast_fallback keyword argument for each method.

Happy Eyeballs Version 2

Happy Eyeballs Version 2 (RFC 8305) is an algorithm designed to improve client socket connectivity.
It aims for more reliable and efficient connections by performing hostname resolution and connection attempts in parallel, instead of serially.

Starting from Ruby 3.4, this method operates as follows with this algorithm:

  1. Start resolving both IPv6 and IPv4 addresses concurrently.

  2. Start connecting to the one of the addresses that are obtained first.
    If IPv4 addresses are obtained first, the method waits 50 ms for IPv6 name resolution to prioritize IPv6 connections.

  3. After starting a connection attempt, wait 250 ms for the connection to be established.
    If no connection is established within this time, a new connection is started every 250 ms
    until a connection is established or there are no more candidate addresses.
    (Although RFC 8305 strictly specifies sorting addresses,
    this method only alternates between IPv6 / IPv4 addresses due to the performance concerns)



  4. Once a connection is established, all remaining connection attempts are canceled.

No documentation available
No documentation available

Invoked as a callback whenever a singleton method is added to the receiver.

module Chatty
  def Chatty.singleton_method_added(id)
    puts "Adding #{id.id2name}"
  end
  def self.one()     end
  def two()          end
  def Chatty.three() end
end

produces:

Adding singleton_method_added
Adding one
Adding three

Invoked as a callback whenever a singleton method is undefined in the receiver.

module Chatty
  def Chatty.singleton_method_undefined(id)
    puts "Undefining #{id.id2name}"
  end
  def Chatty.one()   end
  class << self
     undef_method(:one)
  end
end

produces:

Undefining one
No documentation available
No documentation available

Yields each frame of the current execution stack as a backtrace location object.

Returns the class for the given object.

class A
  def foo
    ObjectSpace::trace_object_allocations do
      obj = Object.new
      p "#{ObjectSpace::allocation_class_path(obj)}"
    end
  end
end

A.new.foo #=> "Class"

See ::trace_object_allocations for more information and examples.

Returns the method identifier for the given object.

class A
  include ObjectSpace

  def foo
    trace_object_allocations do
      obj = Object.new
      p "#{allocation_class_path(obj)}##{allocation_method_id(obj)}"
    end
  end
end

A.new.foo #=> "Class#new"

See ::trace_object_allocations for more information and examples.

Search took: 8ms  ·  Total Results: 3274