Returns true for IPv4-compatible IPv6 address (::/80). It returns false otherwise.
Accepts an incoming connection using accept(2) after O_NONBLOCK is set for the underlying file descriptor. It returns an accepted TCPSocket
for the incoming connection.
require 'socket' serv = TCPServer.new(2202) begin # emulate blocking accept sock = serv.accept_nonblock rescue IO::WaitReadable, Errno::EINTR IO.select([serv]) retry end # sock is an accepted socket.
Refer to Socket#accept
for the exceptions that may be thrown if the call to TCPServer#accept_nonblock
fails.
TCPServer#accept_nonblock
may raise any error corresponding to accept(2) failure, including Errno::EWOULDBLOCK.
If the exception is Errno::EWOULDBLOCK, Errno::EAGAIN, Errno::ECONNABORTED
, Errno::EPROTO
, it is extended by IO::WaitReadable
. So IO::WaitReadable
can be used to rescue the exceptions for retrying accept_nonblock.
By specifying ‘exception: false`, the options hash allows you to indicate that accept_nonblock
should not raise an IO::WaitReadable
exception, but return the symbol :wait_readable instead.
Accepts an incoming connection using accept(2) after O_NONBLOCK is set for the underlying file descriptor. It returns an accepted UNIXSocket
for the incoming connection.
require 'socket' serv = UNIXServer.new("/tmp/sock") begin # emulate blocking accept sock = serv.accept_nonblock rescue IO::WaitReadable, Errno::EINTR IO.select([serv]) retry end # sock is an accepted socket.
Refer to Socket#accept
for the exceptions that may be thrown if the call to UNIXServer#accept_nonblock
fails.
UNIXServer#accept_nonblock
may raise any error corresponding to accept(2) failure, including Errno::EWOULDBLOCK.
If the exception is Errno::EWOULDBLOCK, Errno::EAGAIN, Errno::ECONNABORTED
or Errno::EPROTO
, it is extended by IO::WaitReadable
. So IO::WaitReadable
can be used to rescue the exceptions for retrying accept_nonblock.
By specifying ‘exception: false`, the options hash allows you to indicate that accept_nonblock
should not raise an IO::WaitReadable
exception, but return the symbol :wait_readable instead.
Returns the Encoding
object that represents the encoding of the file. If strio is write mode and no encoding is specified, returns nil
.
Returns the Encoding
of the internal string if conversion is specified. Otherwise returns nil.
Specify the encoding of the StringIO
as ext_enc. Use the default external encoding if ext_enc is nil. 2nd argument int_enc and optional hash opt argument are ignored; they are for API compatibility to IO
.
Duplicates a StringScanner
object.
Return the post-match
(in the regular expression sense) of the last scan.s = StringScanner.new('test string') s.scan(/\w+/) # -> "test" s.scan(/\s+/) # -> " " s.pre_match # -> "test" s.post_match # -> "string"
Stores the pattern of comments to skip from the provided options.
The pattern must respond to .match
, else ArgumentError
is raised. Strings are converted to a Regexp
.
See also CSV.new
Returns the encoding of the internal IO
object or the default
if the encoding cannot be determined.
Creates a new compiler for ERB
. See ERB::Compiler.new for details
‘get_option’ is an alias of ‘get’.
‘each_option’ is an alias of ‘each’.
Returns a string containing the IP address representation in canonical form.
Returns true if the ipaddr is an IPv4-compatible IPv6 address.
Returns a new ipaddr built by converting the native IPv4 address into an IPv4-compatible IPv6 address.
Returns the number of rows.
Returns the submatrix obtained by deleting the specified row and column.
Matrix.diagonal(9, 5, -3, 4).first_minor(1, 2) => 9 0 0 0 0 0 0 0 4
Add option switch like with on
, but at head of summary.
Add option switch like with on
, but at tail of summary.