Reset the scan pointer (index 0) and clear matching data.
Returns the string being scanned.
Changes the string being scanned to str
and resets the scanner. Returns str
.
Looks ahead to see if the pattern
exists anywhere in the string, without advancing the scan pointer. This predicates whether a scan_until
will return a value.
s = StringScanner.new('test string') s.exist? /s/ # -> 3 s.scan /test/ # -> "test" s.exist? /s/ # -> 2 s.exist? /e/ # -> nil
Returns the subgroups in the most recent match (not including the full match). If nothing was priorly matched, it returns nil.
s = StringScanner.new("Fri Dec 12 1975 14:39") s.scan(/(\w+) (\w+) (\d+) /) # -> "Fri Dec 12 " s.captures # -> ["Fri", "Dec", "12"] s.scan(/(\w+) (\w+) (\d+) /) # -> nil s.captures # -> nil
Returns the name of the method.
tobj = WIN32OLE_TYPE.new('Microsoft Excel 9.0 Object Library', 'Workbook') method = WIN32OLE_METHOD.new(tobj, 'SaveAs') puts method.name # => SaveAs
Returns true if argument is return value.
tobj = WIN32OLE_TYPE.new('DirectX 7 for Visual Basic Type Library', 'DirectPlayLobbyConnection') method = WIN32OLE_METHOD.new(tobj, 'GetPlayerShortName') param = method.params[0] puts "#{param.name} #{param.retval?}" # => name true
Returns name.
tobj = WIN32OLE_TYPE.new('Microsoft Excel 9.0 Object Library', 'Workbook') method = WIN32OLE_METHOD.new(tobj, 'SaveAs') param1 = method.params[0] puts param1.name # => Filename
Returns Ruby Hash
object which represents VT_RECORD variable. The keys of Hash
object are member names of VT_RECORD OLE variable and the values of Hash
object are values of VT_RECORD OLE variable.
If COM server in VB.NET ComServer project is the following:
Imports System.Runtime.InteropServices Public Class ComClass Public Structure Book <MarshalAs(UnmanagedType.BStr)> _ Public title As String Public cost As Integer End Structure Public Function getBook() As Book Dim book As New Book book.title = "The Ruby Book" book.cost = 20 Return book End Function End Class
then, the result of WIN32OLE_RECORD#to_h
is the following:
require 'win32ole' obj = WIN32OLE.new('ComServer.ComClass') book = obj.getBook book.to_h # => {"title"=>"The Ruby Book", "cost"=>20}
Returns OLE type name.
tobj = WIN32OLE_TYPE.new('Microsoft Excel 9.0 Object Library', 'Application') puts tobj.name # => Application
Returns the type library name.
tlib = WIN32OLE_TYPELIB.new('Microsoft Excel 9.0 Object Library') name = tlib.name # -> 'Microsoft Excel 9.0 Object Library'
Returns the name of variable.
tobj = WIN32OLE_TYPE.new('Microsoft Excel 9.0 Object Library', 'XlSheetType') variables = tobj.variables variables.each do |variable| puts "#{variable.name}" end The result of above script is following: xlChart xlDialogSheet xlExcel4IntlMacroSheet xlExcel4MacroSheet xlWorksheet
Rebuilds the hash based on the current hash values for each key. If values of key objects have changed since they were inserted, this method will reindex hsh. If Hash#rehash
is called while an iterator is traversing the hash, a RuntimeError
will be raised in the iterator.
a = [ "a", "b" ] c = [ "c", "d" ] h = { a => 100, c => 300 } h[a] #=> 100 a[0] = "z" h[a] #=> nil h.rehash #=> {["z", "b"]=>100, ["c", "d"]=>300} h[a] #=> 100
Returns self
. If called on a subclass of Hash
, converts the receiver to a Hash
object.
If a block is given, the results of the block on each pair of the receiver will be used as pairs.
Converts hsh to a nested array of [
key, value ]
arrays.
h = { "c" => 300, "a" => 100, "d" => 400, "c" => 300 } h.to_a #=> [["c", 300], ["a", 100], ["d", 400]]
Returns a new hash consisting of entries for which the block returns false.
If no block is given, an enumerator is returned instead.
h = { "a" => 100, "b" => 200, "c" => 300 } h.reject {|k,v| k < "b"} #=> {"b" => 200, "c" => 300} h.reject {|k,v| v > 100} #=> {"a" => 100}
Equivalent to Hash#delete_if
, but returns nil
if no changes were made.
Replaces the contents of hsh with the contents of other_hash.
h = { "a" => 100, "b" => 200 } h.replace({ "c" => 300, "d" => 400 }) #=> {"c"=>300, "d"=>400}
Return the contents of this hash as a string.
h = { "c" => 300, "a" => 100, "d" => 400, "c" => 300 } h.to_s #=> "{\"c\"=>300, \"a\"=>100, \"d\"=>400}"
Same as ENV.delete_if
, but works on (and returns) a copy of the environment.
Equivalent to ENV.delete_if
but returns nil
if no changes were made.
Returns an Enumerator
if no block was given.
Replaces the contents of the environment variables with the contents of hash
.
Re-hashing the environment variables does nothing. It is provided for compatibility with Hash
.
Converts the environment variables into an array of names and value arrays.
ENV.to_a # => [["TERM", "xterm-color"], ["SHELL", "/bin/bash"], ...]
Returns “ENV”