Many operating systems allow signals to be sent to running processes. Some signals have a defined effect on the process, while others may be trapped at the code level and acted upon. For example, your process may trap the USR1 signal and use it to toggle debugging, and may use TERM to initiate a controlled shutdown.
pid = fork do Signal.trap("USR1") do $debug = !$debug puts "Debug now: #$debug" end Signal.trap("TERM") do puts "Terminating..." shutdown() end # . . . do some work . . . end Process.detach(pid) # Controlling program: Process.kill("USR1", pid) # ... Process.kill("USR1", pid) # ... Process.kill("TERM", pid)
produces:
Debug now: true Debug now: false Terminating...
The list of available signal names and their interpretation is system dependent. Signal
delivery semantics may also vary between systems; in particular signal delivery may not always be reliable.
Enumerator::ArithmeticSequence
is a subclass of Enumerator
, that is a representation of sequences of numbers with common difference. Instances of this class can be generated by the Range#step
and Numeric#step
methods.
The class can be used for slicing Array
(see Array#slice
) or custom collections.
Raised by Encoding
and String
methods when the source encoding is incompatible with the target encoding.
Subclass of Zlib::Error
When zlib returns a Z_STREAM_END is return if the end of the compressed data has been reached and all uncompressed out put has been produced.
Subclass of Zlib::Error
When zlib returns a Z_STREAM_ERROR, usually if the stream state was inconsistent.
Subclass of Zlib::Error
When zlib returns a Z_MEM_ERROR, usually if there was not enough memory.
A custom InputMethod class used by XMP
for evaluating string io.
Response class for Unauthorized
responses (status code 401).
Authentication is required, but either was not provided or failed.
References:
Response class for Payment Required
responses (status code 402).
Reserved for future use.
References:
Response class for Method Not Allowed
responses (status code 405).
The request method is not supported for the requested resource.
References:
Response class for Proxy Authentication Required
responses (status code 407).
The client must first authenticate itself with the proxy.
References:
Response class for Unsupported Media Type
responses (status code 415).
The request entity has a media type which the server or resource does not support.
References:
Response class for Gateway Timeout
responses (status code 504).
The server was acting as a gateway or proxy and did not receive a timely response from the upstream server.
References:
Response class for Gateway Timeout
responses (status code 504).
The server was acting as a gateway or proxy and did not receive a timely response from the upstream server.
References:
Response class for Network Authentication Required
responses (status code 511).
The client needs to authenticate to gain network access.
References:
Raises when the given argument word can’t be completed uniquely.
The dispatcher class fires events for nodes that are found while walking an AST to all registered listeners. It’s useful for performing different types of analysis on the AST while only having to walk the tree once.
To use the dispatcher, you would first instantiate it and register listeners for the events you’re interested in:
class OctalListener def on_integer_node_enter(node) if node.octal? && !node.slice.start_with?("0o") warn("Octal integers should be written with the 0o prefix") end end end dispatcher = Dispatcher.new dispatcher.register(listener, :on_integer_node_enter)
Then, you can walk any number of trees and dispatch events to the listeners:
result = Prism.parse("001 + 002 + 003") dispatcher.dispatch(result.value)
Optionally, you can also use ‘#dispatch_once` to dispatch enter and leave events for a single node without recursing further down the tree. This can be useful in circumstances where you want to reuse the listeners you already have registers but want to stop walking the tree at a certain point.
integer = result.value.statements.body.first.receiver.receiver dispatcher.dispatch_once(integer)
Represents the use of the ‘alias` keyword to alias a method.
alias foo bar ^^^^^^^^^^^^^
Represents an array pattern in pattern matching.
foo in 1, 2 ^^^^^^^^^^^ foo in [1, 2] ^^^^^^^^^^^^^ foo in *1 ^^^^^^^^^ foo in Bar[] ^^^^^^^^^^^^ foo in Bar[1, 2, 3] ^^^^^^^^^^^^^^^^^^^
Represents assigning to a local variable in pattern matching.
foo => [bar => baz] ^^^^^^^^^^^^
Represents the use of a case statement for pattern matching.
case true in false end ^^^^^^^^^