Returns the parameter name with class name. If the parameter has default value, then returns name=value string with class name.
Returns the OLE struct name and member name and the value of member
If COM server in VB.NET ComServer project is the following:
Imports System.Runtime.InteropServices Public Class ComClass <MarshalAs(UnmanagedType.BStr)> _ Public title As String Public cost As Integer End Class
then
srver = WIN32OLE.new('ComServer.ComClass') obj = WIN32OLE_RECORD.new('Book', server) obj.inspect # => <WIN32OLE_RECORD(ComClass) {"title" => nil, "cost" => nil}>
Returns number which represents type.
tobj = WIN32OLE_TYPE.new('Microsoft Word 10.0 Object Library', 'Documents') puts tobj.typekind # => 4
Returns help string.
tobj = WIN32OLE_TYPE.new('Microsoft Internet Controls', 'IWebBrowser') puts tobj.helpstring # => Web Browser interface
Returns the type name with class name.
ie = WIN32OLE.new('InternetExplorer.Application') ie.ole_type.inspect => #<WIN32OLE_TYPE:IWebBrowser2>
Returns the type library name with class name.
tlib = WIN32OLE_TYPELIB.new('Microsoft Excel 9.0 Object Library') tlib.inspect # => "<#WIN32OLE_TYPELIB:Microsoft Excel 9.0 Object Library>"
Returns the number which represents variable kind.
tobj = WIN32OLE_TYPE.new('Microsoft Excel 9.0 Object Library', 'XlSheetType') variables = tobj.variables variables.each do |variable| puts "#{variable.name} #{variable.varkind}" end The result of above script is following: xlChart 2 xlDialogSheet 2 xlExcel4IntlMacroSheet 2 xlExcel4MacroSheet 2 xlWorksheet 2
Returns the OLE variable name and the value with class name.
Returns a new String containing the hash entries:
h = {foo: 0, bar: 1, baz: 2} h.inspect # => "{:foo=>0, :bar=>1, :baz=>2}"
Hash#to_s
is an alias for Hash#inspect
.
Returns a new Hash object with the each key-value pair inverted:
h = {foo: 0, bar: 1, baz: 2} h1 = h.invert h1 # => {0=>:foo, 1=>:bar, 2=>:baz}
Overwrites any repeated new keys: (see Entry Order):
h = {foo: 0, bar: 0, baz: 0} h.invert # => {0=>:baz}
Methods has_key?
, key?
, and member?
are aliases for #include?.
Returns true
if key
is a key in self
, otherwise false
.
Returns a Hash
whose keys are the ENV
values, and whose values are the corresponding ENV
names:
ENV.replace('foo' => '0', 'bar' => '1') ENV.invert # => {"1"=>"bar", "0"=>"foo"}
For a duplicate ENV
value, overwrites the hash entry:
ENV.replace('foo' => '0', 'bar' => '0') ENV.invert # => {"0"=>"foo"}
Note that the order of the ENV
processing is OS-dependent, which means that the order of overwriting is also OS-dependent. See About Ordering.
Returns the contents of the environment as a String:
ENV.replace('foo' => '0', 'bar' => '1') ENV.inspect # => "{\"bar\"=>\"1\", \"foo\"=>\"0\"}"
ENV.has_key?
, ENV.member?
, and ENV.key?
are aliases for ENV.include?
.
Returns true
if there is an environment variable with the given name
:
ENV.replace('foo' => '0', 'bar' => '1') ENV.include?('foo') # => true
Returns false
if name
is a valid String
and there is no such environment variable:
ENV.include?('baz') # => false
Returns false
if name
is the empty String
or is a String
containing character '='
:
ENV.include?('') # => false ENV.include?('=') # => false
Raises an exception if name
is a String
containing the NUL character "\0"
:
ENV.include?("\0") # Raises ArgumentError (bad environment variable name: contains null byte)
Raises an exception if name
has an encoding that is not ASCII-compatible:
ENV.include?("\xa1\xa1".force_encoding(Encoding::UTF_16LE)) # Raises ArgumentError (bad environment variable name: ASCII incompatible encoding: UTF-16LE)
Raises an exception if name
is not a String:
ENV.include?(Object.new) # TypeError (no implicit conversion of Object into String)
Reads each file in ARGF
in its entirety, returning an Array
containing lines from the files. Lines are assumed to be separated by sep.
lines = ARGF.readlines lines[0] #=> "This is line one\n"
Returns the next line from the current file in ARGF
.
By default lines are assumed to be separated by $/
; to use a different character as a separator, supply it as a String
for the sep argument.
The optional limit argument specifies how many characters of each line to return. By default all characters are returned.
An EOFError
is raised at the end of the file.
Positions the current file to the beginning of input, resetting ARGF.lineno
to zero.
ARGF.readline #=> "This is line one\n" ARGF.rewind #=> 0 ARGF.lineno #=> 0 ARGF.readline #=> "This is line one\n"
Writes the given object(s) to ios. Returns nil
.
The stream must be opened for writing. Each given object that isn’t a string will be converted by calling its to_s
method. When called without arguments, prints the contents of $_
.
If the output field separator ($,
) is not nil
, it is inserted between objects. If the output record separator ($\
) is not nil
, it is appended to the output.
$stdout.print("This is ", 100, " percent.\n")
produces:
This is 100 percent.
Formats and writes to ios, converting parameters under control of the format string. See Kernel#sprintf
for details.
Returns the current line number of ARGF
as a whole. This value can be set manually with ARGF.lineno=
.
For example:
ARGF.lineno #=> 0 ARGF.readline #=> "This is line 1\n" ARGF.lineno #=> 1
Sets the line number of ARGF
as a whole to the given Integer
.
ARGF
sets the line number automatically as you read data, so normally you will not need to set it explicitly. To access the current line number use ARGF.lineno
.
For example:
ARGF.lineno #=> 0 ARGF.readline #=> "This is line 1\n" ARGF.lineno #=> 1 ARGF.lineno = 0 #=> 0 ARGF.lineno #=> 0
Returns “ARGF”.
Creates or retrieves cached CSV objects. For arguments and options, see CSV.new
.
This API is not Ractor-safe.
With no block given, returns a CSV object.
The first call to instance
creates and caches a CSV object:
s0 = 's0' csv0 = CSV.instance(s0) csv0.class # => CSV
Subsequent calls to instance
with that same string
or io
retrieve that same cached object:
csv1 = CSV.instance(s0) csv1.class # => CSV csv1.equal?(csv0) # => true # Same CSV object
A subsequent call to instance
with a different string
or io
creates and caches a different CSV object.
s1 = 's1' csv2 = CSV.instance(s1) csv2.equal?(csv0) # => false # Different CSV object
All the cached objects remains available:
csv3 = CSV.instance(s0) csv3.equal?(csv0) # true # Same CSV object csv4 = CSV.instance(s1) csv4.equal?(csv2) # true # Same CSV object
When a block is given, calls the block with the created or retrieved CSV object; returns the block’s return value:
CSV.instance(s0) {|csv| :foo } # => :foo
Alias for CSV.read
.
Returns the count of the rows parsed or generated.
Parsing:
string = "foo,0\nbar,1\nbaz,2\n" path = 't.csv' File.write(path, string) CSV.open(path) do |csv| csv.each do |row| p [csv.lineno, row] end end
Output:
[1, ["foo", "0"]] [2, ["bar", "1"]] [3, ["baz", "2"]]
Generating:
CSV.generate do |csv| p csv.lineno; csv << ['foo', 0] p csv.lineno; csv << ['bar', 1] p csv.lineno; csv << ['baz', 2] end
Output:
0 1 2