Results for: "pstore"

Deserializes JSON string by converting time since epoch to Time

Stores class name (Time) with number of seconds since epoch and number of microseconds for Time as JSON string

No documentation available

Converts the contents of the database to an in-memory Hash object, and returns it.

Deserializes JSON string by constructing new Struct object with values v serialized by to_json.

Stores class name (Struct) with Struct values v as a JSON string. Only named structs are supported.

Waits until IO is readable without blocking and returns self, or nil when times out. Returns true immediately when buffered data is available.

Synonym for IO.new.

Returns ios.

Closes the read end of a duplex I/O stream (i.e., one that contains both a read and a write stream, such as a pipe). Will raise an IOError if the stream is not duplexed.

Example
f = IO.popen("/bin/sh","r+")
f.close_read
f.readlines

produces:

prog.rb:3:in `readlines': not opened for reading (IOError)
 from prog.rb:3

Calling this method on closed IO object is just ignored since Ruby 2.3.

Reads at most maxlen bytes from ios using the read(2) system call after O_NONBLOCK is set for the underlying file descriptor.

If the optional outbuf argument is present, it must reference a String, which will receive the data. The outbuf will contain only the received data after the method call even if it is not empty at the beginning.

read_nonblock just calls the read(2) system call. It causes all errors the read(2) system call causes: Errno::EWOULDBLOCK, Errno::EINTR, etc. The caller should care such errors.

If the exception is Errno::EWOULDBLOCK or Errno::EAGAIN, it is extended by IO::WaitReadable. So IO::WaitReadable can be used to rescue the exceptions for retrying read_nonblock.

read_nonblock causes EOFError on EOF.

If the read byte buffer is not empty, read_nonblock reads from the buffer like readpartial. In this case, the read(2) system call is not called.

When read_nonblock raises an exception kind of IO::WaitReadable, read_nonblock should not be called until io is readable for avoiding busy loop. This can be done as follows.

Example
# emulates blocking read (readpartial).
begin
  result = io.read_nonblock(maxlen)
rescue IO::WaitReadable
  IO.select([io])
  retry
end

Although IO#read_nonblock doesn’t raise IO::WaitWritable. OpenSSL::Buffering#read_nonblock can raise IO::WaitWritable. If IO and SSL should be used polymorphically, IO::WaitWritable should be rescued too. See the document of OpenSSL::Buffering#read_nonblock for sample code.

Note that this method is identical to readpartial except the non-blocking flag is set.

By specifying a keyword argument exception to false, you can indicate that read_nonblock should not raise an IO::WaitReadable exception, but return the symbol :wait_readable instead. At EOF, it will return nil instead of raising EOFError.

Returns a hash of all key-value pairs contained in the database.

Deserializes JSON string by constructing new Struct object with values t serialized by to_json.

Stores class name (OpenStruct) with this struct’s values v as a JSON string.

Deserializes JSON string by constructing new Range object with arguments a serialized by to_json.

Stores class name (Range) with JSON array of arguments a which include first (integer), last (integer), and exclude_end? (boolean) as JSON string.

Deserializes JSON string by constructing new Regexp object with source s (Regexp or String) and options o serialized by to_json

Stores class name (Regexp) with options o and source s (Regexp or String) as JSON string

The first form returns the MatchData object generated by the last successful pattern match. Equivalent to reading the special global variable $~ (see Special global variables in Regexp for details).

The second form returns the nth field in this MatchData object. n can be a string or symbol to reference a named capture.

Note that the last_match is local to the thread and method scope of the method that did the pattern match.

Example
/c(.)t/ =~ 'cat'        #=> 0
Regexp.last_match       #=> #<MatchData "cat" 1:"a">
Regexp.last_match(0)    #=> "cat"
Regexp.last_match(1)    #=> "a"
Regexp.last_match(2)    #=> nil

/(?<lhs>\w+)\s*=\s*(?<rhs>\w+)/ =~ "var = val"
Regexp.last_match       #=> #<MatchData "var = val" lhs:"var" rhs:"val">
Regexp.last_match(:lhs) #=> "var"
Regexp.last_match(:rhs) #=> "val"

Returns a hash representing information about named captures of rxp.

A key of the hash is a name of the named captures. A value of the hash is an array which is list of indexes of corresponding named captures.

Example
/(?<foo>.)(?<bar>.)/.named_captures
#=> {"foo"=>[1], "bar"=>[2]}

/(?<foo>.)(?<foo>.)/.named_captures
#=> {"foo"=>[1, 2]}

If there are no named captures, an empty hash is returned.

Example
/(.)(.)/.named_captures
#=> {}

Stores class name (Symbol) with String representation of Symbol as a JSON string.

Deserializes JSON string by converting the string value stored in the object to a Symbol

In general, to_sym returns the Symbol corresponding to an object. As sym is already a symbol, self is returned in this case.

Returns a Proc object which responds to the given method by sym.

Example
(1..3).collect(&:to_s)  #=> ["1", "2", "3"]

Returns true if this class can be used to create an instance from a serialised JSON string. The class has to implement a class method json_create that expects a hash as first parameter. The hash should include the required data.

Search took: 6ms  ·  Total Results: 3468