Duplicates the deflate stream.
See Zlib::GzipReader
documentation for a description.
Returns true
if stat is readable by the real user id of this process.
File.stat("testfile").readable_real? #=> true
If stat is writable by others, returns an integer representing the file permission bits of stat. Returns nil
otherwise. The meaning of the bits is platform dependent; on Unix systems, see stat(2)
.
m = File.stat("/tmp").world_writable? #=> 511 sprintf("%o", m) #=> "777"
Make an internal copy of the source buffer. Updates to the copy will not affect the source buffer.
source = IO::Buffer.for("Hello World") # => # #<IO::Buffer 0x00007fd598466830+11 EXTERNAL READONLY SLICE> # 0x00000000 48 65 6c 6c 6f 20 57 6f 72 6c 64 Hello World buffer = source.dup # => # #<IO::Buffer 0x0000558cbec03320+11 INTERNAL> # 0x00000000 48 65 6c 6c 6f 20 57 6f 72 6c 64 Hello World
Read from buffer a value of type
at offset
. buffer_type
should be one of symbols:
:U8
: unsigned integer, 1 byte
:S8
: signed integer, 1 byte
:u16
: unsigned integer, 2 bytes, little-endian
:U16
: unsigned integer, 2 bytes, big-endian
:s16
: signed integer, 2 bytes, little-endian
:S16
: signed integer, 2 bytes, big-endian
:u32
: unsigned integer, 4 bytes, little-endian
:U32
: unsigned integer, 4 bytes, big-endian
:s32
: signed integer, 4 bytes, little-endian
:S32
: signed integer, 4 bytes, big-endian
:u64
: unsigned integer, 8 bytes, little-endian
:U64
: unsigned integer, 8 bytes, big-endian
:s64
: signed integer, 8 bytes, little-endian
:S64
: signed integer, 8 bytes, big-endian
:f32
: float, 4 bytes, little-endian
:F32
: float, 4 bytes, big-endian
:f64
: double, 8 bytes, little-endian
:F64
: double, 8 bytes, big-endian
A buffer type refers specifically to the type of binary buffer that is stored in the buffer. For example, a :u32
buffer type is a 32-bit unsigned integer in little-endian format.
string = [1.5].pack('f') # => "\x00\x00\xC0?" IO::Buffer.for(string).get_value(:f32, 0) # => 1.5
Similar to get_value
, except that it can handle multiple buffer types and returns an array of values.
string = [1.5, 2.5].pack('ff') IO::Buffer.for(string).get_values([:f32, :f32], 0) # => [1.5, 2.5]
Write to a buffer a value
of type
at offset
. type
should be one of symbols described in get_value
.
buffer = IO::Buffer.new(8) # => # #<IO::Buffer 0x0000555f5c9a2d50+8 INTERNAL> # 0x00000000 00 00 00 00 00 00 00 00 buffer.set_value(:U8, 1, 111) # => 1 buffer # => # #<IO::Buffer 0x0000555f5c9a2d50+8 INTERNAL> # 0x00000000 00 6f 00 00 00 00 00 00 .o......
Note that if the type
is integer and value
is Float
, the implicit truncation is performed:
buffer = IO::Buffer.new(8) buffer.set_value(:U32, 0, 2.5) buffer # => # #<IO::Buffer 0x0000555f5c9a2d50+8 INTERNAL> # 0x00000000 00 00 00 02 00 00 00 00 # ^^ the same as if we'd pass just integer 2
Write values
of buffer_types
at offset
to the buffer. buffer_types
should be an array of symbols as described in get_value
. values
should be an array of values to write.
buffer = IO::Buffer.new(8) buffer.set_values([:U8, :U16], 0, [1, 2]) buffer # => # #<IO::Buffer 0x696f717561746978+8 INTERNAL> # 0x00000000 01 00 02 00 00 00 00 00 ........
Returns the full name of this constant. For example: “Foo”
Returns the full name of this constant. For example: “Foo”
Returns the full name of this constant path. For example: “Foo::Bar”
Returns the full name of this constant path. For example: “Foo::Bar”
Returns the full name of this constant. For example: “Foo”
Return the byte offset of the start of the line corresponding to the given byte offset.
The line number where this location starts.
The column number in bytes where this location starts from the start of the line.
Attach the list of comments to their respective locations in the tree.
This only works when the cursor is at the bottom of the scroll range For more details, see github.com/ruby/reline/pull/577#issuecomment-1646679623