Returns the set of bits corresponding to the options used when creating this Regexp
(see Regexp::new
for details. Note that additional bits may be set in the returned options: these are used internally by the regular expression code. These extra bits are ignored if the options are passed to Regexp::new
.
Regexp::IGNORECASE #=> 1 Regexp::EXTENDED #=> 2 Regexp::MULTILINE #=> 4 /cat/.options #=> 0 /cat/ix.options #=> 3 Regexp.new('cat', true).options #=> 1 /\xa1\xa2/e.options #=> 16 r = /cat/ix Regexp.new(r.source, r.options) #=> /cat/ix
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
Returns true
if this is a permutation matrix Raises an error if matrix is not square.
Returns the value as a rational. The optional argument eps is always ignored.
Returns x/y;
Rational(1, 2) #=> (1/2) Rational('1/2') #=> (1/2) Rational(nil) #=> TypeError Rational(1, nil) #=> TypeError
Syntax of string form:
string form = extra spaces , rational , extra spaces ; rational = [ sign ] , unsigned rational ; unsigned rational = numerator | numerator , "/" , denominator ; numerator = integer part | fractional part | integer part , fractional part ; denominator = digits ; integer part = digits ; fractional part = "." , digits , [ ( "e" | "E" ) , [ sign ] , digits ] ; sign = "-" | "+" ; digits = digit , { digit | "_" , digit } ; digit = "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9" ; extra spaces = ? \s* ? ;
See String#to_r
.
Returns the options bitmask used in the last call to open()
Returns an Array of option names.
p FileUtils.options #=> ["noop", "force", "verbose", "preserve", "mode"]
UNTESTED
Get the names of all sections in the current configuration
Get an array of all Instruction
children. IMMUTABLE
Called when an instruction is encountered. EG: <?xsl sheet=‘foo’?> @p name the instruction name; in the example, “xsl” @p instruction the rest of the instruction. In the example, “sheet=‘foo’”
Creates or an HTTP connection based on uri
, or retrieves an existing connection, using a proxy if needed.
Raises PStore::Error
if the calling code is not in a PStore#transaction
or if the code is in a read-only PStore#transaction
.
Returns the status of the global “abort on exception” condition.
The default is false
.
When set to true
, if any thread is aborted by an exception, the raised exception will be re-raised in the main thread.
Can also be specified by the global $DEBUG flag or command line option -d
.
See also ::abort_on_exception=
.
There is also an instance level method to set this for a specific thread, see abort_on_exception
.
When set to true
, if any thread is aborted by an exception, the raised exception will be re-raised in the main thread. Returns the new state.
Thread.abort_on_exception = true t1 = Thread.new do puts "In new thread" raise "Exception from thread" end sleep(1) puts "not reached"
This will produce:
In new thread prog.rb:4: Exception from thread (RuntimeError) from prog.rb:2:in `initialize' from prog.rb:2:in `new' from prog.rb:2
See also ::abort_on_exception
.
There is also an instance level method to set this for a specific thread, see abort_on_exception=
.
Returns the status of the thread-local “abort on exception” condition for this thr
.
The default is false
.
See also abort_on_exception=
.
There is also a class level method to set this for all threads, see ::abort_on_exception
.
When set to true
, if this thr
is aborted by an exception, the raised exception will be re-raised in the main thread.
See also abort_on_exception
.
There is also a class level method to set this for all threads, see ::abort_on_exception=
.
Starts tracing object allocations from the ObjectSpace
extension module.
For example:
require 'objspace' class C include ObjectSpace def foo trace_object_allocations do obj = Object.new p "#{allocation_sourcefile(obj)}:#{allocation_sourceline(obj)}" end end end C.new.foo #=> "objtrace.rb:8"
This example has included the ObjectSpace
module to make it easier to read, but you can also use the ::trace_object_allocations
notation (recommended).
Note that this feature introduces a huge performance decrease and huge memory consumption.