Closes the incoming port and returns whether it was already closed. All further attempts to Ractor.receive
in the ractor, and send
to the ractor will fail with Ractor::ClosedError
.
r = Ractor.new {sleep(500)} r.close_incoming #=> false r.close_incoming #=> true r.send('test') # Ractor::ClosedError (The incoming-port is already closed)
Returns whether or not the asynchronous queue is empty.
Since Thread::handle_interrupt
can be used to defer asynchronous events, this method can be used to determine if there are any deferred events.
If you find this method returns true, then you may finish :never
blocks.
For example, the following method processes deferred asynchronous events immediately.
def Thread.kick_interrupt_immediately Thread.handle_interrupt(Object => :immediate) { Thread.pass } end
If error
is given, then check only for error
type deferred events.
th = Thread.new{ Thread.handle_interrupt(RuntimeError => :on_blocking){ while true ... # reach safe point to invoke interrupt if Thread.pending_interrupt? Thread.handle_interrupt(Object => :immediate){} end ... end } } ... th.raise # stop thread
This example can also be written as the following, which you should use to avoid asynchronous interrupts.
flag = true th = Thread.new{ Thread.handle_interrupt(RuntimeError => :on_blocking){ while true ... # reach safe point to invoke interrupt break if flag == false ... end } } ... flag = false # stop thread
Returns whether or not the asynchronous queue is empty for the target thread.
If error
is given, then check only for error
type deferred events.
See ::pending_interrupt?
for more information.
Compiled instruction sequence represented by a RubyVM::InstructionSequence
instance on the :script_compiled
event.
Note that this method is MRI specific.
Returns a string containing the RFC-2045-compliant Base64-encoding of bin
.
Per RFC 2045, the returned string may contain the URL-unsafe characters +
or /
; see Encoding Character Set above:
Base64.strict_encode64("\xFB\xEF\xBE") # => "++++\n" Base64.strict_encode64("\xFF\xFF\xFF") # => "////\n"
The returned string may include padding; see Padding above.
Base64.strict_encode64('*') # => "Kg==\n"
The returned string will have no newline characters, regardless of its length; see Newlines above:
Base64.strict_encode64('*') # => "Kg==" Base64.strict_encode64('*' * 46) # => "KioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKg=="
The string to be encoded may itself contain newlines, which will be encoded as ordinary Base64:
Base64.strict_encode64("\n\n\n") # => "CgoK" s = "This is line 1\nThis is line 2\n" Base64.strict_encode64(s) # => "VGhpcyBpcyBsaW5lIDEKVGhpcyBpcyBsaW5lIDIK"
Returns a string containing the decoding of an RFC-2045-compliant Base64-encoded string str
:
s = "VGhpcyBpcyBsaW5lIDEKVGhpcyBpcyBsaW5lIDIK" Base64.strict_decode64(s) # => "This is line 1\nThis is line 2\n"
Non-Base64 characters in str
not allowed; see Encoding Character Set above: these include newline characters and characters -
and /
:
Base64.strict_decode64("\n") # Raises ArgumentError Base64.strict_decode64('-') # Raises ArgumentError Base64.strict_decode64('_') # Raises ArgumentError
Padding in str
, if present, must be correct:
Base64.strict_decode64("MDEyMzQ1Njc") # Raises ArgumentError Base64.strict_decode64("MDEyMzQ1Njc=") # => "01234567" Base64.strict_decode64("MDEyMzQ1Njc==") # Raises ArgumentError
Adds a post-install hook that will be passed an Gem::Installer
instance when Gem::Installer#install
is called
Adds a post-uninstall hook that will be passed a Gem::Uninstaller
instance and the spec that was uninstalled when Gem::Uninstaller#uninstall
is called
Returns the destination encoding as an encoding object.
Returns the destination encoding as an encoding object.
Returns the destination encoding as an Encoding
object.
Returns true if this comment happens on the same line as other code and false if the comment is by itself.
This can only be true for inline comments.
Create a new InstanceVariableReadNode
node
Create a new InstanceVariableTargetNode
node
Create a new InterpolatedMatchLastLineNode
node
Returns the index of the last element for which object == element
.
When argument object
is given but no block, returns the index of the last such element found:
a = [:foo, 'bar', 2, 'bar'] a.rindex('bar') # => 3
Returns nil
if no such object found.
When a block is given but no argument, calls the block with each successive element; returns the index of the last element for which the block returns a truthy value:
a = [:foo, 'bar', 2, 'bar'] a.rindex {|element| element == 'bar' } # => 3
Returns nil
if the block never returns a truthy value.
When neither an argument nor a block is given, returns a new Enumerator:
a = [:foo, 'bar', 2, 'bar'] e = a.rindex e # => #<Enumerator: [:foo, "bar", 2, "bar"]:rindex> e.each {|element| element == 'bar' } # => 3
Related: index
.
Returns 1
if either self.real.infinite?
or self.imag.infinite?
is true, nil
otherwise:
Complex(Float::INFINITY, 0).infinite? # => 1 Complex(1, 1).infinite? # => nil
Related: Numeric#infinite?
, Float#infinite?
.
Returns nil
, -1, or 1 depending on whether self
is finite, -Infinity
, or +Infinity
.
Returns:
1, if self
is Infinity
.
-1 if self
is -Infinity
.
nil
, otherwise.
Examples:
f = 1.0/0.0 # => Infinity f.infinite? # => 1 f = -1.0/0.0 # => -Infinity f.infinite? # => -1 f = 1.0 # => 1.0 f.infinite? # => nil f = 0.0/0.0 # => NaN f.infinite? # => nil