Results for: "module_function"

Returns true if the set and the given set have at least one element in common.

Set[1, 2, 3].intersect? Set[4, 5]   #=> false
Set[1, 2, 3].intersect? Set[3, 4]   #=> true

Equivalent to Set#delete_if, but returns nil if no changes were made. Returns an enumerator if no block is given.

Deletes every element that appears in the given enumerable object and returns self.

No documentation available

Returns a string containing a human-readable representation of the set (“#<Set: {element1, element2, …}>”).

No documentation available
No documentation available

Unlinks (deletes) the file from the filesystem. One should always unlink the file after using it, as is explained in the “Explicit close” good practice section in the Tempfile overview:

file = Tempfile.new('foo')
begin
   # ...do something with file...
ensure
   file.close
   file.unlink   # deletes the temp file
end

On POSIX systems it’s possible to unlink a file before closing it. This practice is explained in detail in the Tempfile overview (section “Unlink after creation”); please refer there for more information.

However, unlink-before-close may not be supported on non-POSIX operating systems. Microsoft Windows is the most notable case: unlinking a non-closed file will result in an error, which this method will silently ignore. If you want to practice unlink-before-close whenever possible, then you should write code like this:

file = Tempfile.new('foo')
file.unlink   # On Windows this silently fails.
begin
   # ... do something with file ...
ensure
   file.close!   # Closes the file handle. If the file wasn't unlinked
                 # because #unlink failed, then this method will attempt
                 # to do so again.
end

The string representation of true is “true”.

The string representation of false is “false”.

Return a string containing a human-readable TracePoint status.

Returns the unique identifier for this proc, along with an indication of where the proc was defined.

The reason this block was terminated: :break, :redo, :retry, :next, :return, or :noreason.

Returns a clone of this method.

class A
  def foo
    return "bar"
  end
end

m = A.new.method(:foo)
m.call # => "bar"
n = m.clone.call # => "bar"

Returns a human-readable description of the underlying method.

"cat".method(:count).inspect   #=> "#<Method: String#count>"
(1..3).method(:map).inspect    #=> "#<Method: Range(Enumerable)#map>"

In the latter case, the method description includes the “owner” of the original method (Enumerable module, which is included into Range).

Dissociates meth from its current receiver. The resulting UnboundMethod can subsequently be bound to a new object of the same class (see UnboundMethod).

Returns a clone of this method.

class A
  def foo
    return "bar"
  end
end

m = A.new.method(:foo)
m.call # => "bar"
n = m.clone.call # => "bar"

Returns a human-readable description of the underlying method.

"cat".method(:count).inspect   #=> "#<Method: String#count>"
(1..3).method(:map).inspect    #=> "#<Method: Range(Enumerable)#map>"

In the latter case, the method description includes the “owner” of the original method (Enumerable module, which is included into Range).

Wakes up thr, making it eligible for scheduling.

a = Thread.new { puts "a"; Thread.stop; puts "c" }
sleep 0.1 while a.status!='sleep'
puts "Got here"
a.run
a.join

This will produce:

a
Got here
c

See also the instance method wakeup.

Returns the priority of thr. Default is inherited from the current thread which creating the new thread, or zero for the initial main thread; higher-priority thread will run more frequently than lower-priority threads (but lower-priority threads can also run).

This is just hint for Ruby thread scheduler. It may be ignored on some platform.

Thread.current.priority   #=> 0

Sets the priority of thr to integer. Higher-priority threads will run more frequently than lower-priority threads (but lower-priority threads can also run).

This is just hint for Ruby thread scheduler. It may be ignored on some platform.

count1 = count2 = 0
a = Thread.new do
      loop { count1 += 1 }
    end
a.priority = -1

b = Thread.new do
      loop { count2 += 1 }
    end
b.priority = -2
sleep 1   #=> 1
count1    #=> 622504
count2    #=> 5832

Dump the name, id, and status of thr to a string.

Prevents threads from being added to or removed from the receiving ThreadGroup.

New threads can still be started in an enclosed ThreadGroup.

ThreadGroup::Default.enclose        #=> #<ThreadGroup:0x4029d914>
thr = Thread.new { Thread.stop }    #=> #<Thread:0x402a7210 sleep>
tg = ThreadGroup.new                #=> #<ThreadGroup:0x402752d4>
tg.add thr
#=> ThreadError: can't move from the enclosed thread group

Returns true if the thgrp is enclosed. See also ThreadGroup#enclose.

Releases the lock. Raises ThreadError if mutex wasn’t locked by the current thread.

Search took: 6ms  ·  Total Results: 3710