Results for: "Logger"

See Zlib::GzipReader documentation for a description.

See Zlib::GzipReader documentation for a description.

See Zlib::GzipReader documentation for a description.

See Zlib::GzipReader documentation for a description.

See Zlib::GzipReader documentation for a description. However, note that this method can return nil even if eof? returns false, unlike the behavior of File#gets.

Returns the number of native file system blocks allocated for this file, or nil if the operating system doesn’t support this feature.

File.stat("testfile").blocks   #=> 2

Returns true if stat is a zero-length file; false otherwise.

File.stat("testfile").zero?   #=> false

Returns true if the file is a block device, false if it isn’t or if the operating system doesn’t support this feature.

File.stat("testfile").blockdev?    #=> false
File.stat("/dev/hda1").blockdev?   #=> true

Transfers ownership of the underlying memory to a new buffer, causing the current buffer to become uninitialized.

buffer = IO::Buffer.new('test')
other = buffer.transfer
other
# =>
# #<IO::Buffer 0x00007f136a15f7b0+4 SLICE>
# 0x00000000  74 65 73 74                                     test
buffer
# =>
# #<IO::Buffer 0x0000000000000000+0 NULL>
buffer.null?
# => true

The buffer is external if it references the memory which is not allocated or mapped by the buffer itself.

A buffer created using ::for has an external reference to the string’s memory.

External buffer can’t be resized.

If the buffer is internal, meaning it references memory allocated by the buffer itself.

An internal buffer is not associated with any external memory (e.g. string) or file mapping.

Internal buffers are created using ::new and is the default when the requested size is less than the IO::Buffer::PAGE_SIZE and it was not requested to be mapped on creation.

Internal buffers can be resized, and such an operation will typically invalidate all slices, but not always.

If the buffer is locked, meaning it is inside locked block execution. Locked buffer can’t be resized or freed, and another lock can’t be acquired on it.

Locking is not thread safe, but is a semantic used to ensure buffers don’t move while being used by a system call.

buffer.locked do
  buffer.write(io) # theoretical system call interface
end

Allows to process a buffer in exclusive way, for concurrency-safety. While the block is performed, the buffer is considered locked, and no other code can enter the lock. Also, locked buffer can’t be changed with resize or free.

The following operations acquire a lock: resize, free.

Locking is not thread safe. It is designed as a safety net around non-blocking system calls. You can only share a buffer between threads with appropriate synchronisation techniques.

buffer = IO::Buffer.new(4)
buffer.locked? #=> false

Fiber.schedule do
  buffer.locked do
    buffer.write(io) # theoretical system call interface
  end
end

Fiber.schedule do
  # in `locked': Buffer already locked! (IO::Buffer::LockedError)
  buffer.locked do
    buffer.set_string("test", 0)
  end
end

Returns a new Tms object obtained by memberwise operation op of the individual times for this Tms object with those of the other Tms object (x).

op can be a mathematical operation such as +, -, *, /

Store session data on the server and close the session storage. For some session storage types, this is a no-op.

Reads the next expression from this printer.

See IO#gets for more information.

Returns true; retained for compatibility.

Sends a GET request and returns the HTTP response body as a string.

With string arguments hostname and path:

hostname = 'jsonplaceholder.typicode.com'
path = '/todos/1'
puts Net::HTTP.get(hostname, path)

Output:

{
  "userId": 1,
  "id": 1,
  "title": "delectus aut autem",
  "completed": false
}

With URI object uri and optional hash argument headers:

uri = URI('https://jsonplaceholder.typicode.com/todos/1')
headers = {'Content-type' => 'application/json; charset=UTF-8'}
Net::HTTP.get(uri, headers)

Related:

Sends a GET request to the server; returns an instance of a subclass of Net::HTTPResponse.

The request is based on the Net::HTTP::Get object created from string path and initial headers hash initheader.

With a block given, calls the block with the response body:

http = Net::HTTP.new(hostname)
http.get('/todos/1') do |res|
  p res
end # => #<Net::HTTPOK 200 OK readbody=true>

Output:

"{\n  \"userId\": 1,\n  \"id\": 1,\n  \"title\": \"delectus aut autem\",\n  \"completed\": false\n}"

With no block given, simply returns the response object:

http.get('/') # => #<Net::HTTPOK 200 OK readbody=true>

Related:

Sends a LOCK request to the server; returns an instance of a subclass of Net::HTTPResponse.

The request is based on the Net::HTTP::Lock object created from string path, string body, and initial headers hash initheader.

data = '{"userId": 1, "id": 1, "title": "delectus aut autem", "completed": false}'
http = Net::HTTP.new(hostname)
http.lock('/todos/1', data)

Sends an UNLOCK request to the server; returns an instance of a subclass of Net::HTTPResponse.

The request is based on the Net::HTTP::Unlock object created from string path, string body, and initial headers hash initheader.

data = '{"userId": 1, "id": 1, "title": "delectus aut autem", "completed": false}'
http = Net::HTTP.new(hostname)
http.unlock('/todos/1', data)
No documentation available
No documentation available

Returns the binary operator used to modify the receiver. This method is deprecated in favor of binary_operator.

Returns the binary operator used to modify the receiver. This method is deprecated in favor of binary_operator.

Search took: 4ms  ·  Total Results: 2278