Results for: "String# "

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.

Returns true for IPv6 multicast link-local scope address. It returns false otherwise.

No documentation available
No documentation available
No documentation available
No documentation available
No documentation available

Initialize WIN32OLE object(ActiveX Control) by calling IPersistMemory::InitNew.

Before calling OLE method, some kind of the ActiveX controls created with MFC should be initialized by calling IPersistXXX::InitNew.

If and only if you received the exception “HRESULT error code: 0x8000ffff catastrophic failure”, try this method before invoking any ole_method.

obj = WIN32OLE.new("ProgID_or_GUID_of_ActiveX_Control")
obj.ole_activex_initialize
obj.method(...)

Returns WIN32OLE object for a specific dispatch or dual interface specified by iid.

ie = WIN32OLE.new('InternetExplorer.Application')
ie_web_app = ie.ole_query_interface('{0002DF05-0000-0000-C000-000000000046}') # => WIN32OLE object for dispinterface IWebBrowserApp

Returns IO instance tied to ARGF for writing if inplace mode is enabled.

Returns the value of the local variable symbol.

def foo
  a = 1
  binding.local_variable_get(:a) #=> 1
  binding.local_variable_get(:b) #=> NameError
end

This method is the short version of the following code:

binding.eval("#{symbol}")

Set local variable named symbol as obj.

def foo
  a = 1
  bind = binding
  bind.local_variable_set(:a, 2) # set existing local variable `a'
  bind.local_variable_set(:b, 3) # create new local variable `b'
                                 # `b' exists only in binding

  p bind.local_variable_get(:a)  #=> 2
  p bind.local_variable_get(:b)  #=> 3
  p a                            #=> 2
  p b                            #=> NameError
end

This method behaves similarly to the following code:

binding.eval("#{symbol} = #{obj}")

if obj can be dumped in Ruby code.

Creates an option from the given parameters params. See Parameters for New Options.

The block, if given, is the handler for the created option. When the option is encountered during command-line parsing, the block is called with the argument given for the option, if any. See Option Handlers.

Defines options which set in to options for keyword parameters of method.

Parameters for each keywords are given as elements of params.

Breaks the buffer into lines that are shorter than maxwidth

If the correponding value is not set, yield a value with init_block and store the value in thread-safe manner. This method returns corresponding stored value.

(1..10).map{
  Thread.new(it){|i|
    Ractor.store_if_absent(:s){ f(); i }
    #=> return stored value of key :s
  }
}.map(&:value).uniq.size #=> 1 and f() is called only once

Returns the value of a thread local variable that has been set. Note that these are different than fiber local values. For fiber local values, please see Thread#[] and Thread#[]=.

Thread local values are carried along with threads, and do not respect fibers. For example:

Thread.new {
  Thread.current.thread_variable_set("foo", "bar") # set a thread local
  Thread.current["foo"] = "bar"                    # set a fiber local

  Fiber.new {
    Fiber.yield [
      Thread.current.thread_variable_get("foo"), # get the thread local
      Thread.current["foo"],                     # get the fiber local
    ]
  }.resume
}.join.value # => ['bar', nil]

The value “bar” is returned for the thread local, where nil is returned for the fiber local. The fiber is executed in the same thread, so the thread local values are available.

Sets a thread local with key to value. Note that these are local to threads, and not to fibers. Please see Thread#thread_variable_get and Thread#[] for more information.

Establishes proc on thr as the handler for tracing, or disables tracing if the parameter is nil.

See Kernel#set_trace_func.

Adds proc as a handler for tracing.

See Thread#set_trace_func and Kernel#set_trace_func.

Establishes proc as the handler for tracing, or disables tracing if the parameter is nil.

Note: this method is obsolete, please use TracePoint instead.

proc takes up to six parameters:

proc is invoked whenever an event occurs.

Events are:

"c-call"

call a C-language routine

"c-return"

return from a C-language routine

"call"

call a Ruby method

"class"

start a class or module definition

"end"

finish a class or module definition

"line"

execute code on a new line

"raise"

raise an exception

"return"

return from a Ruby method

Tracing is disabled within the context of proc.

class Test
  def test
    a = 1
    b = 2
  end
end

set_trace_func proc { |event, file, line, id, binding, class_or_module|
  printf "%8s %s:%-2d %16p %14p\n", event, file, line, id, class_or_module
}
t = Test.new
t.test

Produces:

c-return prog.rb:8   :set_trace_func         Kernel
    line prog.rb:11              nil            nil
  c-call prog.rb:11             :new          Class
  c-call prog.rb:11      :initialize    BasicObject
c-return prog.rb:11      :initialize    BasicObject
c-return prog.rb:11             :new          Class
    line prog.rb:12              nil            nil
    call prog.rb:2             :test           Test
    line prog.rb:3             :test           Test
    line prog.rb:4             :test           Test
  return prog.rb:5             :test           Test

Invoke self.each with *args. With a block given, the block receives each element and its index; returns self:

h = {}
(1..4).each_with_index {|element, i| h[element] = i } # => 1..4
h # => {1=>0, 2=>1, 3=>2, 4=>3}

h = {}
%w[a b c d].each_with_index {|element, i| h[element] = i }
# => ["a", "b", "c", "d"]
h # => {"a"=>0, "b"=>1, "c"=>2, "d"=>3}

a = []
h = {foo: 0, bar: 1, baz: 2}
h.each_with_index {|element, i| a.push([i, element]) }
# => {:foo=>0, :bar=>1, :baz=>2}
a # => [[0, [:foo, 0]], [1, [:bar, 1]], [2, [:baz, 2]]]

With no block given, returns an Enumerator.

No documentation available

Attempts to enter exclusive section. Returns false if lock fails.

For backward compatibility

Search took: 7ms  ·  Total Results: 4158