Returns the major part of File_Stat#dev
or nil
.
File.stat("/dev/fd1").dev_major #=> 2 File.stat("/dev/tty").dev_major #=> 5
Returns the major part of File_Stat#rdev
or nil
.
File.stat("/dev/fd1").rdev_major #=> 2 File.stat("/dev/tty").rdev_major #=> 5
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 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 memcpy
.
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.
Returns serialized iseq binary format data as a String
object. A corresponding iseq object is created by RubyVM::InstructionSequence.load_from_binary()
method.
String
extra_data will be saved with binary data. You can access this data with RubyVM::InstructionSequence.load_from_binary_extra_data(binary)
.
Note that the translated binary data is not portable. You can not move this binary data to another machine. You can not use the binary data which is created by another version/another architecture of Ruby.
Returns the number of the first source line where the instruction sequence was loaded from.
For example, using irb:
iseq = RubyVM::InstructionSequence.compile('num = 1 + 2') #=> <RubyVM::InstructionSequence:<compiled>@<compiled>> iseq.first_lineno #=> 1
Return trace points in the instruction sequence. Return an array of [line, event_symbol] pair.
It returns recorded script lines if it is available. The script lines are not limited to the iseq range, but are entire lines of the source file.
Note that this is an API for ruby internal use, debugging, and research. Do not use this for any other purpose. The compatibility is not guaranteed.
Like Net::HTTP.get
, but writes the returned body to $stdout; returns nil
.
Sets the continue timeout value, which is the number of seconds to wait for an expected 100 Continue response. If the HTTP object does not receive a response in this many seconds it sends the request body.
true if the response has a body.
Sets the encoding that should be used when reading the body:
If the given value is an Encoding
object, that encoding will be used.
Otherwise if the value is a string, the value of Encoding#find(value) will be used.
Otherwise an encoding will be deduced from the body itself.
Examples:
http = Net::HTTP.new(hostname) req = Net::HTTP::Get.new('/') http.request(req) do |res| p res.body.encoding # => #<Encoding:ASCII-8BIT> end http.request(req) do |res| res.body_encoding = "UTF-8" p res.body.encoding # => #<Encoding:UTF-8> end