Expands lazy
enumerator to an array. See Enumerable#to_a
.
Returns the string representation of the bignum.
BN.new
can parse the encoded string to convert back into an OpenSSL::BN
.
base
The format. Must be one of the following:
0
- MPI format. See the man page BN_bn2mpi(3) for details.
2
- Variable-length and big-endian binary encoding. The sign of the bignum is ignored.
10
- Decimal number representation, with a leading ‘-’ for a negative bignum.
16
- Hexadecimal number representation, with a leading ‘-’ for a negative bignum.
Returns the authentication code as a hex-encoded string. The digest parameter specifies the digest algorithm to use. This may be a String
representing the algorithm name or an instance of OpenSSL::Digest
.
key = 'key' data = 'The quick brown fox jumps over the lazy dog' hmac = OpenSSL::HMAC.hexdigest('SHA1', key, data) #=> "de7c9b85b8b78aa6bc8a7a36f70a90701c9db4d9"
Gets the parsable form of the current configuration.
Given the following configuration file being loaded:
config = OpenSSL::Config.load('baz.cnf') #=> #<OpenSSL::Config sections=["default"]> puts config.to_s #=> [ default ] # foo=bar # baz=buz
You can get the serialized configuration using to_s
and then parse it later:
serialized_config = config.to_s # much later... new_config = OpenSSL::Config.parse(serialized_config) #=> #<OpenSSL::Config sections=["default"]> puts new_config #=> [ default ] foo=bar baz=buz
returns the socket option data as a string.
p Socket::Option.new(:INET6, :IPV6, :RECVPKTINFO, [1].pack("i!")).data #=> "\x01\x00\x00\x00"
Short representation of the buffer. It includes the address, size and symbolic flags. This format is subject to change.
puts IO::Buffer.new(4) # uses to_s internally # #<IO::Buffer 0x000055769f41b1a0+4 INTERNAL>
Returns an Array
with 14 elements representing the instruction sequence with the following data:
A string identifying the data format. Always YARVInstructionSequence/SimpleDataFormat
.
The major version of the instruction sequence.
The minor version of the instruction sequence.
A number identifying the data format. Always 1.
A hash containing:
:arg_size
the total number of arguments taken by the method or the block (0 if iseq doesn’t represent a method or block)
:local_size
the number of local variables + 1
:stack_max
used in calculating the stack depth at which a SystemStackError
is thrown.
label
The name of the context (block, method, class, module, etc.) that this instruction sequence belongs to.
<main>
if it’s at the top level, <compiled>
if it was evaluated from a string.
path
The relative path to the Ruby
file where the instruction sequence was loaded from.
<compiled>
if the iseq was evaluated from a string.
absolute_path
The absolute path to the Ruby
file where the instruction sequence was loaded from.
nil
if the iseq was evaluated from a string.
first_lineno
The number of the first source line where the instruction sequence was loaded from.
The type of the instruction sequence.
Valid values are :top
, :method
, :block
, :class
, :rescue
, :ensure
, :eval
, :main
, and plain
.
An array containing the names of all arguments and local variables as symbols.
An Hash
object containing parameter information.
More info about these values can be found in vm_core.h
.
A list of exceptions and control flow operators (rescue, next, redo, break, etc.).
An array of arrays containing the instruction names and operands that make up the body of the instruction sequence.
Note that this format is MRI specific and version dependent.
Convert the Cookie
to its string representation.
Convert back to the [name, version, platform] tuple
Renders the document back to a string
Renders the given line
Also allows us to represent source code as an array of code lines.
When we have an array of code line elements calling ‘join` on the array will call `to_s` on each element, which essentially converts it back into it’s original source string.