Read a chunk or all of the buffer into a string, in the specified encoding
. If no encoding is provided Encoding::BINARY
is used.
buffer = IO::Buffer.for('test') buffer.get_string # => "test" buffer.get_string(2) # => "st" buffer.get_string(2, 1) # => "s"
Efficiently copy from a source String
into the buffer, at offset
using memmove
.
buf = IO::Buffer.new(8) # => # #<IO::Buffer 0x0000557412714a20+8 INTERNAL> # 0x00000000 00 00 00 00 00 00 00 00 ........ # set buffer starting from offset 1, take 2 bytes starting from string's # second buf.set_string('test', 1, 2, 1) # => 2 buf # => # #<IO::Buffer 0x0000557412714a20+8 INTERNAL> # 0x00000000 00 65 73 00 00 00 00 00 .es.....
See also copy
for examples of how buffer writing might be used for changing associated strings and files.
Sanitize a single string.
Create a new StringNode
node.
Retrieve the value of one of the StringFlags
flags.
If the SOURCE_DATE_EPOCH environment variable is set, returns it’s value. Otherwise, returns the time that Gem.source_date_epoch_string
was first called in the same format as SOURCE_DATE_EPOCH.
NOTE(@duckinator): The implementation is a tad weird because we want to:
1. Make builds reproducible by default, by having this function always return the same result during a given run. 2. Allow changing ENV['SOURCE_DATE_EPOCH'] at runtime, since multiple tests that set this variable will be run in a single process.
If you simplify this function and a lot of tests fail, that is likely due to #2 above.
Details on SOURCE_DATE_EPOCH: reproducible-builds.org/specs/source-date-epoch/
Create a new XStringNode
node.
Create a new InterpolatedStringNode
node.
Compile a StringNode
node
Dispatch enter and leave events for StringNode
nodes and continue walking the tree.
Inspect a StringNode
node.
Copy a StringNode
node
in “” in “foo”
Concatenates each object in objects
into self
without any encoding validation or conversion and returns self
:
s = 'foo' s.append_as_bytes(" \xE2\x82") # => "foo \xE2\x82" s.valid_encoding? # => false s.append_as_bytes("\xAC 12") s.valid_encoding? # => true
For each given object object
that is an Integer
, the value is considered a Byte. If the Integer
is bigger than one byte, only the lower byte is considered, similar to String#setbyte
:
s = "" s.append_as_bytes(0, 257) # => "\u0000\u0001"
Related: String#<<
, String#concat
, which do an encoding aware concatenation.
Returns the value returned by method name
.
Returns a status string for the response.
Returns the human readable error string corresponding to the error code retrieved by error
.
See also the man page X509_verify_cert_error_string(3).
This method is provided by the Ripper
C extension. It is called when a string needs to be dedented because of a tilde heredoc. It is expected that it will modify the string in place and return the number of bytes that were removed.
Create a new InterpolatedXStringNode
node.