Results for: "max_by"

if /foo #{bar}/ then end

^^^^^^^^^^^^
No documentation available

Creates a new Socket::Option object which contains a byte as data.

p Socket::Option.byte(:INET, :SOCKET, :KEEPALIVE, 1)
#=> #<Socket::Option: INET SOCKET KEEPALIVE 1>

Returns the data in sockopt as an byte.

sockopt = Socket::Option.byte(:INET, :SOCKET, :KEEPALIVE, 1)
p sockopt.byte => 1

See Zlib::GzipReader documentation for a description.

Iterates over the buffer, yielding each byte starting from offset.

If count is given, only count bytes will be yielded.

IO::Buffer.for("Hello World").each_byte(2, 2) do |offset, byte|
  puts "#{offset}: #{byte}"
end
# 2: 108
# 3: 108
No documentation available
No documentation available
No documentation available
No documentation available

True if version satisfies this Requirement.

No documentation available

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 a String with length number of cryptographically strong pseudo-random bytes.

Example

OpenSSL::Random.random_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.

Generate 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”.

require 'random/formatter'

Random.random_bytes #=> "\xD8\\\xE0\xF4\r\xB2\xFC*WM\xFF\x83\x18\xF45\xB6"
# or
prng = Random.new
prng.random_bytes #=> "m\xDC\xFC/\a\x00Uf\xB2\xB2P\xBD\xFF6S\x97"

Returns the DER-encoded bytes of the certificate’s to be signed certificate. This is mainly useful for validating embedded certificate transparency signatures.

No documentation available

The parser gem automatically converts rn to n, meaning our offsets need to be adjusted to always subtract 1 from the length.

Number of bytes read out of the tar entry

Returns the byte at zero-based index as an integer, or nil if index is out of range:

s = 'abcde'   # => "abcde"
s.getbyte(0)  # => 97
s.getbyte(-1) # => 101
s.getbyte(5)  # => nil

Related: String#setbyte.

Sets the byte at zero-based index to integer; returns integer:

s = 'abcde'      # => "abcde"
s.setbyte(0, 98) # => 98
s                # => "bbcde"

Related: String#getbyte.

For the given method names, marks the method as passing keywords through a normal argument splat. This should only be called on methods that accept an argument splat (*args) but not explicit keywords or a keyword splat. It marks the method such that if the method is called with keyword arguments, the final hash argument is marked with a special flag such that if it is the final element of a normal argument splat to another method call, and that method call does not include explicit keywords or a keyword splat, the final element is interpreted as keywords. In other words, keywords will be passed through the method to other methods.

This should only be used for methods that delegate keywords to another method, and only for backwards compatibility with Ruby versions before 3.0. See www.ruby-lang.org/en/news/2019/12/12/separation-of-positional-and-keyword-arguments-in-ruby-3-0/ for details on why ruby2_keywords exists and when and how to use it.

This method will probably be removed at some point, as it exists only for backwards compatibility. As it does not exist in Ruby versions before 2.7, check that the module responds to this method before calling it:

module Mod
  def foo(meth, *args, &block)
    send(:"do_#{meth}", *args, &block)
  end
  ruby2_keywords(:foo) if respond_to?(:ruby2_keywords, true)
end

However, be aware that if the ruby2_keywords method is removed, the behavior of the foo method using the above approach will change so that the method does not pass through keywords.

Search took: 17ms  ·  Total Results: 557