Returns the type library file path.
tlib = WIN32OLE_TYPELIB.new('Microsoft Excel 9.0 Object Library') puts tlib.path #-> 'C:\...\EXCEL9.OLB'
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
Same as IO
.
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.
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.
Returns the last access time for this file as an object of class Time
.
File.stat("testfile").atime #=> Wed Dec 31 18:00:00 CST 1969
Returns true
if the file is a character device, false
if it isn’t or if the operating system doesn’t support this feature.
File.stat("/dev/tty").chardev? #=> true
Create an IO::Buffer
for reading from file
by memory-mapping the file. file_io
should be a File
instance, opened for reading.
Optional size
and offset
of mapping can be specified.
By default, the buffer would be immutable (read only); to create a writable mapping, you need to open a file in read-write mode, and explicitly pass flags
argument without IO::Buffer::IMMUTABLE.
File.write('test.txt', 'test') buffer = IO::Buffer.map(File.open('test.txt'), nil, 0, IO::Buffer::READONLY) # => #<IO::Buffer 0x00000001014a0000+4 MAPPED READONLY> buffer.readonly? # => true buffer.get_string # => "test" buffer.set_string('b', 0) # `set_string': Buffer is not writable! (IO::Buffer::AccessError) # create read/write mapping: length 4 bytes, offset 0, flags 0 buffer = IO::Buffer.map(File.open('test.txt', 'r+'), 4, 0) buffer.set_string('b', 0) # => 1 # Check it File.read('test.txt') # => "best"
Note that some operating systems may not have cache coherency between mapped buffers and file reads.
If the buffer is mapped, meaning it references memory mapped by the buffer.
Mapped buffers are either anonymous, if created by ::new
with the IO::Buffer::MAPPED
flag or if the size was at least IO::Buffer::PAGE_SIZE
, or backed by a file if created with ::map
.
Mapped buffers can usually 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"
Iterates over the buffer, yielding each value
of buffer_type
starting from offset
.
If count
is given, only count
values will be yielded.
IO::Buffer.for("Hello World").each(:U8, 2, 2) do |offset, value| puts "#{offset}: #{value}" end # 2: 108 # 3: 108
Returns the path of this instruction sequence.
<compiled>
if the iseq was evaluated from a string.
For example, using irb:
iseq = RubyVM::InstructionSequence.compile('num = 1 + 2') #=> <RubyVM::InstructionSequence:<compiled>@<compiled>> iseq.path #=> "<compiled>"
Using ::compile_file
:
# /tmp/method.rb def hello puts "hello, world" end # in irb > iseq = RubyVM::InstructionSequence.compile_file('/tmp/method.rb') > iseq.path #=> /tmp/method.rb
Set
path for which this cookie applies
Set
domain for which this cookie applies
Store session data on the server. For some session storage types, this is a no-op.
Calls the block with each header-value pair; returns self
:
source = "Name,Name,Name\nFoo,Bar,Baz\n" table = CSV.parse(source, headers: true) row = table[0] row.each {|header, value| p [header, value] }
Output:
["Name", "Foo"] ["Name", "Bar"] ["Name", "Baz"]
If no block is given, returns a new Enumerator:
row.each # => #<Enumerator: #<CSV::Row "Name":"Foo" "Name":"Bar" "Name":"Baz">:each>
Calls the block with each row or column; returns self
.
When the access mode is :row
or :col_or_row
, calls the block with each CSV::Row object:
source = "Name,Value\nfoo,0\nbar,1\nbaz,2\n" table = CSV.parse(source, headers: true) table.by_row! # => #<CSV::Table mode:row row_count:4> table.each {|row| p row }
Output:
#<CSV::Row "Name":"foo" "Value":"0"> #<CSV::Row "Name":"bar" "Value":"1"> #<CSV::Row "Name":"baz" "Value":"2">
When the access mode is :col
, calls the block with each column as a 2-element array containing the header and an Array of column fields:
table.by_col! # => #<CSV::Table mode:col row_count:4> table.each {|column_data| p column_data }
Output:
["Name", ["foo", "bar", "baz"]] ["Value", ["0", "1", "2"]]
Returns a new Enumerator if no block is given:
table.each # => #<Enumerator: #<CSV::Table mode:col row_count:4>:each>