Results for: "to_proc"

Similar to method, searches singleton method only.

class Demo
  def initialize(n)
    @iv = n
  end
  def hello()
    "Hello, @iv = #{@iv}"
  end
end

k = Demo.new(99)
def k.hi
  "Hi, @iv = #{@iv}"
end
m = k.singleton_method(:hi)
m.call   #=> "Hi, @iv = 99"
m = k.singleton_method(:hello) #=> NameError

Returns true if obj responds to the given method. Private and protected methods are included in the search only if the optional second parameter evaluates to true.

If the method is not implemented, as Process.fork on Windows, File.lchmod on GNU/Linux, etc., false is returned.

If the method is not defined, respond_to_missing? method is called and the result is returned.

When the method name parameter is given as a string, the string is converted to a symbol.

Returns true if mod is a singleton class or false if it is an ordinary class or module.

class C
end
C.singleton_class?                  #=> false
C.singleton_class.singleton_class?  #=> true

Set the cursor position at column in the same line of the current position.

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

Returns a new binding each time near TOPLEVEL_BINDING for runs that do not specify a binding.

Creates a new ipaddr containing the given network byte ordered string form of an IP address.

Returns the measured GC total time in nanoseconds.

How String Gem paths should be split. Overridable for esoteric platforms.

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

Compile a BlockLocalVariableNode node

Dispatch enter and leave events for BlockLocalVariableNode nodes and continue walking the tree.

Inspect a BlockLocalVariableNode node.

Copy a BlockLocalVariableNode node

No documentation available

Parses the most indented lines into blocks that are marked and added to the frontier

With a block given, calls the block with each successive element of self; stops if the block returns false or nil; returns a new array omitting those elements for which the block returned a truthy value; does not modify self:

a = [0, 1, 2, 3, 4, 5]
a.drop_while {|element| element < 3 } # => [3, 4, 5]

With no block given, returns a new Enumerator.

Related: see Methods for Fetching.

Returns a copy of self with leading substring prefix removed:

'hello'.delete_prefix('hel')      # => "lo"
'hello'.delete_prefix('llo')      # => "hello"
'тест'.delete_prefix('те')        # => "ст"
'こんにちは'.delete_prefix('こん')  # => "にちは"

Related: String#delete_prefix!, String#delete_suffix.

Like String#delete_prefix, except that self is modified in place. Returns self if the prefix is removed, nil otherwise.

Returns the next-smaller representable Float.

These examples show the internally stored values (64-bit hexadecimal) for each Float f and for the corresponding f.pev_float:

f = 5e-324   # 0x0000000000000001
f.prev_float # 0x0000000000000000

f = 0.01     # 0x3f847ae147ae147b
f.prev_float # 0x3f847ae147ae147a

In the remaining examples here, the output is shown in the usual way (result to_s):

0.01.prev_float   # => 0.009999999999999998
1.0.prev_float    # => 0.9999999999999999
100.0.prev_float  # => 99.99999999999999

f = 0.01
(0..3).each_with_index {|i| printf "%2d %-20a %s\n", i, f, f.to_s; f = f.prev_float }

Output:

0 0x1.47ae147ae147bp-7 0.01
1 0x1.47ae147ae147ap-7 0.009999999999999998
2 0x1.47ae147ae1479p-7 0.009999999999999997
3 0x1.47ae147ae1478p-7 0.009999999999999995

Related: Float#next_float.

Like backtrace, but returns each line of the execution stack as a Thread::Backtrace::Location. Accepts the same arguments as backtrace.

f = Fiber.new { Fiber.yield }
f.resume
loc = f.backtrace_locations.first
loc.label  #=> "yield"
loc.path   #=> "test.rb"
loc.lineno #=> 1
Search took: 8ms  ·  Total Results: 2407