True if version
satisfies this Requirement
.
Returns the discarded bytes when Encoding::InvalidByteSequenceError
occurs.
ec = Encoding::Converter.new("EUC-JP", "ISO-8859-1") begin ec.convert("abc\xA1\xFFdef") rescue Encoding::InvalidByteSequenceError p $! #=> #<Encoding::InvalidByteSequenceError: "\xA1" followed by "\xFF" on EUC-JP> puts $!.error_bytes.dump #=> "\xA1" puts $!.readagain_bytes.dump #=> "\xFF" end
Returns the bytes to be read again when Encoding::InvalidByteSequenceError
occurs.
Calls the given block once for each byte in the stream.
Generates string
with length
number of cryptographically strong pseudo-random bytes.
Example: OpenSSL::Random.random_bytes(12) => "..."
Generates string
with length
number of pseudo-random bytes.
Pseudo-random byte sequences generated by ::pseudo_bytes
will be unique if they are of sufficient length, but are not necessarily unpredictable.
Example: OpenSSL::Random.pseudo_bytes(12) => "..."
Queries the entropy gathering daemon EGD on socket path given by filename
.
Fetches length
number of bytes and uses ::add to seed the OpenSSL
built-in PRNG.
SecureRandom.random_bytes generates a random binary string.
The argument n specifies the length of the result string.
If n is not specified or is nil, 16 is assumed. It may be larger in future.
The result may contain any byte: “x00” - “xff”.
p SecureRandom.random_bytes #=> "\xD8\\\xE0\xF4\r\xB2\xFC*WM\xFF\x83\x18\xF45\xB6" p SecureRandom.random_bytes #=> "m\xDC\xFC/\a\x00Uf\xB2\xB2P\xBD\xFF6S\x97"
If a secure random number generator is not available, NotImplementedError
is raised.
Number of bytes read out of the tar entry
Determines whether the given ‘requirement` is satisfied by the given `spec`, in the context of the current `activated` dependency graph.
@param [Object] requirement @param [DependencyGraph] activated the current dependency graph in the
resolution process.
@param [Object] spec @return [Boolean] whether ‘requirement` is satisfied by `spec` in the
context of the current `activated` dependency graph.
returns the indexth byte as an integer.
modifies the indexth byte as integer.
Gets the next 8-bit byte (0..255) from ios. Returns nil
if called at end of file.
f = File.new("testfile") f.getbyte #=> 84 f.getbyte #=> 104
Reads a byte as with IO#getbyte
, but raises an EOFError
on end of file.
Pushes back bytes (passed as a parameter) onto ios, such that a subsequent buffered read will return it. Only one byte may be pushed back before a subsequent read operation (that is, you will be able to read only the last of several bytes that have been pushed back). Has no effect with unbuffered reads (such as IO#sysread
).
f = File.new("testfile") #=> #<File:testfile> b = f.getbyte #=> 0x38 f.ungetbyte(b) #=> nil f.getbyte #=> 0x38
Obtains the host information for hostname.
p Socket.gethostbyname("hal") #=> ["localhost", ["hal"], 2, "\x7F\x00\x00\x01"]
Obtains the host information for address.
p Socket.gethostbyaddr([221,186,184,68].pack("CCCC")) #=> ["carbon.ruby-lang.org", [], 2, "\xDD\xBA\xB8D"]
Obtains the port number for service_name.
If protocol_name is not given, “tcp” is assumed.
Socket.getservbyname("smtp") #=> 25 Socket.getservbyname("shell") #=> 514 Socket.getservbyname("syslog", "udp") #=> 514
Obtains the port number for port.
If protocol_name is not given, “tcp” is assumed.
Socket.getservbyport(80) #=> "www" Socket.getservbyport(514, "tcp") #=> "shell" Socket.getservbyport(514, "udp") #=> "syslog"
Lookups host information by hostname.
TCPSocket.gethostbyname("localhost") #=> ["localhost", ["hal"], 2, "127.0.0.1"]