Raised when a signal is received.
begin Process.kill('HUP',Process.pid) sleep # wait for receiver to handle signal sent by Process.kill rescue SignalException => e puts "received Exception #{e}" end
produces:
received Exception SIGHUP
Raised when OLE processing failed.
EX:
obj = WIN32OLE.new("NonExistProgID")
raises the exception:
WIN32OLERuntimeError: unknown OLE server: `NonExistProgID' HRESULT error code:0x800401f3 Invalid class string
Raised when attempting to divide an integer by 0.
42 / 0 #=> ZeroDivisionError: divided by 0
Note that only division by an exact 0 will raise the exception:
42 / 0.0 #=> Float::INFINITY 42 / -0.0 #=> -Float::INFINITY 0 / 0.0 #=> NaN
Ruby supports two forms of objectified methods. Class
Method
is used to represent methods that are associated with a particular object: these method objects are bound to that object. Bound method objects for an object can be created using Object#method
.
Ruby also supports unbound methods; methods objects that are not associated with a particular object. These can be created either by calling Module#instance_method
or by calling unbind on a bound method object. The result of both of these is an UnboundMethod
object.
Unbound methods can only be called after they are bound to an object. That object must be a kind_of? the method’s original class.
class Square def area @side * @side end def initialize(side) @side = side end end area_un = Square.instance_method(:area) s = Square.new(12) area = area_un.bind(s) area.call #=> 144
Unbound methods are a reference to the method at the time it was objectified: subsequent changes to the underlying class will not affect the unbound method.
class Test def test :original end end um = Test.instance_method(:test) class Test def test :modified end end t = Test.new t.test #=> :modified um.bind(t).call #=> :original
Response class for Unavailable For Legal Reasons
responses (status code 451).
A server operator has received a legal demand to deny access to a resource or to a set of resources that includes the requested resource.
References:
Represents a regular expression literal that contains interpolation.
/foo #{bar} baz/ ^^^^^^^^^^^^^^^^
Represents a regular expression literal with no interpolation.
/foo/i ^^^^^^
Represents a singleton class declaration involving the ‘class` keyword.
class << self end ^^^^^^^^^^^^^^^^^
Helper methods for both Gem::Installer
and Gem::Uninstaller
FIXME: This isn’t documented in Nutshell.
Since MonitorMixin.new_cond
returns a ConditionVariable
, and the example above calls while_wait and signal, this class should be documented.
Response class for Precondition Failed
responses (status code 412).
The server does not meet one of the preconditions specified in the request headers.
References:
Response class for Expectation Failed
responses (status code 417).
The server cannot meet the requirements of the Expect request-header field.
References:
This visitor walks through the tree and copies each node as it is being visited. This is useful for consumers that want to mutate the tree, as you can change subtrees in place without effecting the rest of the tree.
ConditionVariable
objects augment class Mutex
. Using condition variables, it is possible to suspend while in the middle of a critical section until a resource becomes available.
Example:
mutex = Thread::Mutex.new resource = Thread::ConditionVariable.new a = Thread.new { mutex.synchronize { # Thread 'a' now needs the resource resource.wait(mutex) # 'a' can now have the resource } } b = Thread.new { mutex.synchronize { # Thread 'b' has finished using the resource resource.signal } }
Module
that defines the default UserInteraction
. Any class including this module will have access to the ui
method that returns the default UI.
Represents an alternation pattern in pattern matching.
foo => bar | baz ^^^^^^^^^
Represents an optional keyword parameter to a method, block, or lambda definition.
def a(b: 1) ^^^^ end
Represents an optional parameter to a method, block, or lambda definition.
def a(b = 1) ^^^^^ end