SyntaxSuggest.valid?
[Private]
Returns truthy if a given input source is valid syntax
SyntaxSuggest.valid?(<<~EOM) # => true def foo end EOM SyntaxSuggest.valid?(<<~EOM) # => false def foo def bar # Syntax error here end EOM
You can also pass in an array of lines and they’ll be joined before evaluating
SyntaxSuggest.valid?( [ "def foo\n", "end\n" ] ) # => true SyntaxSuggest.valid?( [ "def foo\n", " def bar\n", # Syntax error here "end\n" ] ) # => false
As an FYI the CodeLine
class instances respond to ‘to_s` so passing a CodeLine
in as an object or as an array will convert it to it’s code representation.
Returns the arc tangent of y
and x
in radians.
Domain of y
: [-INFINITY, INFINITY]
.
Domain of x
: [-INFINITY, INFINITY]
.
Range: [-PI, PI]
.
Examples:
atan2(-1.0, -1.0) # => -2.356194490192345 # -3*PI/4 atan2(-1.0, 0.0) # => -1.5707963267948966 # -PI/2 atan2(-1.0, 1.0) # => -0.7853981633974483 # -PI/4 atan2(0.0, -1.0) # => 3.141592653589793 # PI
Returns the tangent of x
in radians.
Domain: (-INFINITY, INFINITY)
.
Range: (-INFINITY, INFINITY)
.
Examples:
tan(-PI) # => 1.2246467991473532e-16 # -0.0000000000000001 tan(-PI/2) # => -1.633123935319537e+16 # -16331239353195370.0 tan(0.0) # => 0.0 tan(PI/2) # => 1.633123935319537e+16 # 16331239353195370.0 tan(PI) # => -1.2246467991473532e-16 # -0.0000000000000001
Returns the arc tangent of x
.
Domain: [-INFINITY, INFINITY]
.
Range: [-PI/2, PI/2]
.
Examples:
atan(-INFINITY) # => -1.5707963267948966 # -PI2 atan(-PI) # => -1.2626272556789115 atan(-PI/2) # => -1.0038848218538872 atan(0.0) # => 0.0 atan(PI/2) # => 1.0038848218538872 atan(PI) # => 1.2626272556789115 atan(INFINITY) # => 1.5707963267948966 # PI/2
Returns the hyperbolic tangent of x
in radians.
Domain: [-INFINITY, INFINITY]
.
Range: [-1, 1]
.
Examples:
tanh(-INFINITY) # => -1.0 tanh(0.0) # => 0.0 tanh(INFINITY) # => 1.0
Returns the inverse hyperbolic tangent of x
.
Domain: [-1, 1]
.
Range: [-INFINITY, INFINITY]
.
Examples:
atanh(-1.0) # => -Infinity atanh(0.0) # => 0.0 atanh(1.0) # => Infinity
Sends a signal to each process specified by ids
(which must specify at least one ID); returns the count of signals sent.
For each given id
, if id
is:
Positive, sends the signal to the process whose process ID is id
.
Zero, send the signal to all processes in the current process group.
Negative, sends the signal to a system-dependent collection of processes.
Argument signal
specifies the signal to be sent; the argument may be:
An integer signal number: e.g., -29
, 0
, 29
.
A signal name (string), with or without leading 'SIG'
, and with or without a further prefixed minus sign ('-'
): e.g.:
'SIGPOLL'
.
'POLL'
,
'-SIGPOLL'
.
'-POLL'
.
A signal symbol, with or without leading 'SIG'
, and with or without a further prefixed minus sign ('-'
): e.g.:
:SIGPOLL
.
:POLL
.
:'-SIGPOLL'
.
:'-POLL'
.
If signal
is:
A non-negative integer, or a signal name or symbol without prefixed '-'
, each process with process ID id
is signalled.
A negative integer, or a signal name or symbol with prefixed '-'
, each process group with group ID id
is signalled.
Use method Signal.list
to see which signals are supported by Ruby on the underlying platform; the method returns a hash of the string names and non-negative integer values of the supported signals. The size and content of the returned hash varies widely among platforms.
Additionally, signal 0
is useful to determine if the process exists.
Example:
pid = fork do Signal.trap('HUP') { puts 'Ouch!'; exit } # ... do some work ... end # ... Process.kill('HUP', pid) Process.wait
Output:
Ouch!
Exceptions:
Raises Errno::EINVAL or RangeError
if signal
is an integer but invalid.
Raises ArgumentError
if signal
is a string or symbol but invalid.
Raises Errno::ESRCH or RangeError
if one of ids
is invalid.
Raises Errno::EPERM if needed permissions are not in force.
In the last two cases, signals may have been sent to some processes.
Avoids the potential for a child process to become a zombie process. Process.detach
prevents this by setting up a separate Ruby thread whose sole job is to reap the status of the process pid when it terminates.
This method is needed only when the parent process will never wait for the child process.
This example does not reap the second child process; that process appears as a zombie in the process status (ps
) output:
pid = Process.spawn('ruby', '-e', 'exit 13') # => 312691 sleep(1) # Find zombies. system("ps -ho pid,state -p #{pid}")
Output:
312716 Z
This example also does not reap the second child process, but it does detach the process so that it does not become a zombie:
pid = Process.spawn('ruby', '-e', 'exit 13') # => 313213 thread = Process.detach(pid) sleep(1) # => #<Process::Waiter:0x00007f038f48b838 run> system("ps -ho pid,state -p #{pid}") # Finds no zombies.
The waiting thread can return the pid of the detached child process:
thread.join.pid # => 313262
Example:
x.foo ^^^^ x.foo(42) ^^^^ x&.foo ^^^^^ x[42] ^^^^ x += 1 ^
Compile a ConstantTargetNode
node
Dispatch enter and leave events for ConstantTargetNode
nodes and continue walking the tree.
Inspect a ConstantTargetNode
node.
Get all gem names from the command line.
Returns every spec that matches name
and optional requirements
.
Activate TLS_FALLBACK_SCSV for this context. See RFC 7507.
Visit one side of an alias global variable node.