returns the socket option data as a string.
p Socket::Option.new(:INET6, :IPV6, :RECVPKTINFO, [1].pack("i!")).data #=> "\x01\x00\x00\x00"
Calls String#unpack
on sockopt.data.
sockopt = Socket::Option.new(:INET, :SOCKET, :KEEPALIVE, [1].pack("i")) p sockopt.unpack("i") #=> [1] p sockopt.data.unpack("i") #=> [1]
— Registry.create
(key, subkey, desired = KEY_ALL_ACCESS, opt = REG_OPTION_RESERVED)
— Registry.create
(key, subkey, desired = KEY_ALL_ACCESS, opt = REG_OPTION_RESERVED) { |reg| … }
Create or open the registry key subkey under key. You can use predefined key HKEY_* (see Constants
)
If subkey is already exists, key is opened and Registry#created?
method will return false.
If block is given, the key is closed automatically.
Returns if key is created ((newly)). (see Registry.create
) – basically you call create then when you call created? on the instance returned it will tell if it was successful or not
Same as Win32::Registry.create
(self, subkey, desired, opt)
disconnects OLE server. If this method called, then the WIN32OLE::Event
object does not receive the OLE server event any more. This method is trial implementation.
ie = WIN32OLE.new('InternetExplorer.Application') ev = WIN32OLE::Event.new(ie) ev.on_event() { something } # ... ev.unadvise
Returns true if argument is optional.
tobj = WIN32OLE::Type.new('Microsoft Excel 9.0 Object Library', 'Workbook') method = WIN32OLE::Method.new(tobj, 'SaveAs') param1 = method.params[0] puts "#{param1.name} #{param1.optional?}" # => Filename true
Compresses the given string
. Valid values of level are Zlib::NO_COMPRESSION, Zlib::BEST_SPEED, Zlib::BEST_COMPRESSION, Zlib::DEFAULT_COMPRESSION, or an integer from 0 to 9.
This method is almost equivalent to the following code:
def deflate(string, level) z = Zlib::Deflate.new(level) dst = z.deflate(string, Zlib::FINISH) z.close dst end
See also Zlib.inflate
Inputs string
into the deflate stream and returns the output from the stream. On calling this method, both the input and the output buffers of the stream are flushed. If string
is nil, this method finishes the stream, just like Zlib::ZStream#finish
.
If a block is given consecutive deflated chunks from the string
are yielded to the block and nil
is returned.
The flush
parameter specifies the flush mode. The following constants may be used:
The default
Flushes the output to a byte boundary
SYNC_FLUSH + resets the compression state
Pending input is processed, pending output is flushed.
See the constants for further description.
Decompresses string
. Raises a Zlib::NeedDict
exception if a preset dictionary is needed for decompression.
This method is almost equivalent to the following code:
def inflate(string) zstream = Zlib::Inflate.new buf = zstream.inflate(string) zstream.finish zstream.close buf end
See also Zlib.deflate
Inputs deflate_string
into the inflate stream and returns the output from the stream. Calling this method, both the input and the output buffer of the stream are flushed. If string is nil
, this method finishes the stream, just like Zlib::ZStream#finish
.
If a block is given consecutive inflated chunks from the deflate_string
are yielded to the block and nil
is returned.
If a :buffer keyword argument is given and not nil:
The :buffer keyword should be a String
, and will used as the output buffer. Using this option can reuse the memory required during inflation.
When not passing a block, the return value will be the same object as the :buffer keyword argument.
When passing a block, the yielded chunks will be the same value as the :buffer keyword argument.
Raises a Zlib::NeedDict
exception if a preset dictionary is needed to decompress. Set
the dictionary by Zlib::Inflate#set_dictionary
and then call this method again with an empty string to flush the stream:
inflater = Zlib::Inflate.new begin out = inflater.inflate compressed rescue Zlib::NeedDict # ensure the dictionary matches the stream's required dictionary raise unless inflater.adler == Zlib.adler32(dictionary) inflater.set_dictionary dictionary inflater.inflate '' end # ... inflater.close
See also Zlib::Inflate.new
Returns last modification time recorded in the gzip file header.
Returns comments recorded in the gzip file header, or nil if the comments is not present.
Specify the modification time (mtime
) in the gzip header. Using an Integer
.
Setting the mtime in the gzip header does not effect the mtime of the file generated. Different utilities that expand the gzipped files may use the mtime header. For example the gunzip utility can use the ‘-N` flag which will set the resultant file’s mtime to the value in the header. By default many tools will set the mtime of the expanded file to the mtime of the gzipped file, not the mtime in the header.
If you do not set an mtime, the default value will be the time when compression started. Setting a value of 0 indicates no time stamp is available.
Specify the comment (str
) in the gzip header.
Decompresses all gzip data in the io
, handling multiple gzip streams until the end of the io
. There should not be any non-gzip data after the gzip streams.
If a block is given, it is yielded strings of uncompressed data, and the method returns nil
. If a block is not given, the method returns the concatenation of all uncompressed data in all gzip streams.
Reads at most maxlen bytes from the gziped stream but it blocks only if gzipreader has no data immediately available. If the optional outbuf argument is present, it must reference a String
, which will receive the data. It raises EOFError
on end of file.
Returns the modification time of stat.
File.stat("testfile").mtime #=> Wed Apr 09 08:53:14 CDT 2003
Returns the change time for stat (that is, the time directory information about the file was changed, not the file itself).
Note that on Windows (NTFS), returns creation time (birth time).
File.stat("testfile").ctime #=> Wed Apr 09 08:53:14 CDT 2003
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 private, meaning modifications to the buffer will not be replicated to the underlying file mapping.
# Create a test file: File.write('test.txt', 'test') # Create a private mapping from the given file. Note that the file here # is opened in read-only mode, but it doesn't matter due to the private # mapping: buffer = IO::Buffer.map(File.open('test.txt'), nil, 0, IO::Buffer::PRIVATE) # => #<IO::Buffer 0x00007fce63f11000+4 MAPPED PRIVATE> # Write to the buffer (invoking CoW of the underlying file buffer): buffer.set_string('b', 0) # => 1 # The file itself is not modified: File.read('test.txt') # => "test"
Returns the contents of this Tms
object as a formatted string, according to a format
string like that passed to Kernel.format
. In addition, format
accepts the following extensions:
%u
Replaced by the user CPU time, as reported by Tms#utime
.
%y
Replaced by the system CPU time, as reported by stime
(Mnemonic: y of “s*y*stem”)
%U
Replaced by the children’s user CPU time, as reported by Tms#cutime
%Y
Replaced by the children’s system CPU time, as reported by Tms#cstime
%t
Replaced by the total CPU time, as reported by Tms#total
%r
Replaced by the elapsed real time, as reported by Tms#real
%n
Replaced by the label string, as reported by Tms#label
(Mnemonic: n of “*n*ame”)
If format
is not given, FORMAT
is used as default value, detailing the user, system and real elapsed time.
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 +
, -
, *
, /
Parse a raw cookie string into a hash of cookie-name=>Cookie pairs.
cookies = CGI::Cookie.parse("raw_cookie_string") # { "name1" => cookie1, "name2" => cookie2, ... }