Runs OLE method. The first argument specifies the method name of OLE Automation object. The others specify argument of the method. If you can not execute method directly, then use this method instead.
excel = WIN32OLE.new('Excel.Application') excel.invoke('Quit') # => same as excel.Quit
Runs the early binding method. The 1st argument specifies dispatch ID, the 2nd argument specifies the array of arguments, the 3rd argument specifies the array of the type of arguments.
excel = WIN32OLE.new('Excel.Application') excel._invoke(302, [], []) # same effect as excel.Quit
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.
Hash#store is an alias for Hash#[]=.
Associates the given value with the given key; returns value.
If the given key exists, replaces its value with the given value; the ordering is not affected (see Entry Order):
h = {foo: 0, bar: 1} h[:foo] = 2 # => 2 h.store(:bar, 3) # => 3 h # => {:foo=>2, :bar=>3}
If key does not exist, adds the key and value; the new entry is last in the order (see Entry Order):
h = {foo: 0, bar: 1} h[:baz] = 2 # => 2 h.store(:bat, 3) # => 3 h # => {:foo=>0, :bar=>1, :baz=>2, :bat=>3}
Returns the count of entries in self:
{foo: 0, bar: 1, baz: 2}.length # => 3
Hash#length is an alias for Hash#size.
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.
ENV.store is an alias for ENV.[]=.
Creates, updates, or deletes the named environment variable, returning the value. Both name and value may be instances of String. See Valid Names and Values.
If the named environment variable does not exist:
If value is nil, does nothing.
ENV.clear ENV['foo'] = nil # => nil ENV.include?('foo') # => false ENV.store('bar', nil) # => nil ENV.include?('bar') # => false
If value is not nil, creates the environment variable with name and value:
# Create 'foo' using ENV.[]=. ENV['foo'] = '0' # => '0' ENV['foo'] # => '0' # Create 'bar' using ENV.store. ENV.store('bar', '1') # => '1' ENV['bar'] # => '1'
If the named environment variable exists:
If value is not nil, updates the environment variable with value value:
# Update 'foo' using ENV.[]=. ENV['foo'] = '2' # => '2' ENV['foo'] # => '2' # Update 'bar' using ENV.store. ENV.store('bar', '3') # => '3' ENV['bar'] # => '3'
If value is nil, deletes the environment variable:
# Delete 'foo' using ENV.[]=. ENV['foo'] = nil # => nil ENV.include?('foo') # => false # Delete 'bar' using ENV.store. ENV.store('bar', nil) # => nil ENV.include?('bar') # => false
Raises an exception if name or value is invalid. See Invalid Names and Values.
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\"}"
Returns the count of environment variables:
ENV.replace('foo' => '0', 'bar' => '1') ENV.length # => 2 ENV.size # => 2
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"
Puts ARGF into binary mode. Once a stream is in binary mode, it cannot be reset to non-binary mode. This option has the following effects:
Newline conversion is disabled.
Encoding conversion is disabled.
Content is treated as ASCII-8BIT.
Returns true if ARGF is being read in binary mode; false otherwise. To enable binary mode use ARGF.binmode.
For example:
ARGF.binmode? #=> false ARGF.binmode ARGF.binmode? #=> true
Writes string if inplace mode.
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”.
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
Returns the line most recently read:
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, csv.line] end end
Output:
[1, "foo,0\n"] [2, "bar,1\n"] [3, "baz,2\n"]