Returns a new ipaddr built by converting the native IPv4 address into an IPv4-compatible IPv6 address.
Returns a string for DNS reverse lookup compatible with RFC3172.
Returns a string for DNS reverse lookup compatible with RFC1886.
Returns the names of the binding’s local variables as symbols.
def foo a = 1 2.times do |n| binding.local_variables #=> [:a, :n] end end
This method is the short version of the following code:
binding.eval("local_variables")
Returns the submatrix obtained by deleting the specified row and column.
Matrix.diagonal(9, 5, -3, 4).first_minor(1, 2) # => 9 0 0 # 0 0 0 # 0 0 4
Returns the sharing detection flag as a boolean value. It is false (nil) by default.
Sets the sharing detection flag to b.
Returns the portion of the original string after the current match. Equivalent to the special variable $'
.
m = /(.)(.)(\d+)(\d)/.match("THX1138: The Movie") m.post_match #=> ": The Movie"
Returns the factorization of value
.
For an arbitrary integer:
p_1**e_1 * p_2**e_2 * ... * p_n**e_n,
prime_division
returns an array of pairs of integers:
[[p_1, e_1], [p_2, e_2], ..., [p_n, e_n]].
Each pair consists of a prime number – a prime factor – and a natural number – its exponent (multiplicity).
value
An arbitrary integer.
generator
Optional. A pseudo-prime generator. generator
.succ must return the next pseudo-prime number in ascending order. It must generate all prime numbers, but may also generate non-prime numbers, too.
ZeroDivisionError
when value
is zero.
Prime.prime_division(45) #=> [[3, 2], [5, 1]] 3**2 * 5 #=> 45
Raises PStore::Error
if the calling code is not in a PStore#transaction
.
List of options that will be supplied to RDoc
Returns the original name of the method.
class C def foo; end alias bar foo end C.instance_method(:bar).original_name # => :foo
Returns the original name of the method.
class C def foo; end alias bar foo end C.instance_method(:bar).original_name # => :foo
Returns an array of the names of the thread-local variables (as Symbols).
thr = Thread.new do Thread.current.thread_variable_set(:cat, 'meow') Thread.current.thread_variable_set("dog", 'woof') end thr.join #=> #<Thread:0x401b3f10 dead> thr.thread_variables #=> [:dog, :cat]
Note that these are not fiber local variables. Please see Thread#[]
and Thread#thread_variable_get
for more details.
Returns true
if the given string (or symbol) exists as a thread-local variable.
me = Thread.current me.thread_variable_set(:oliver, "a") me.thread_variable?(:oliver) #=> true me.thread_variable?(:stanley) #=> false
Note that these are not fiber local variables. Please see Thread#[]
and Thread#thread_variable_get
for more details.
Returns the execution stack for the target thread—an array containing backtrace location objects.
See Thread::Backtrace::Location
for more information.
This method behaves similarly to Kernel#caller_locations
except it applies to a specific thread.
Attempts to obtain the lock and returns immediately. Returns true
if the lock was granted.
Returns an array of the names of global variables. This includes special regexp global variables such as $~
and $+
, but does not include the numbered regexp global variables ($1
, $2
, etc.).
global_variables.grep /std/ #=> [:$stdin, :$stdout, :$stderr]
Controls tracing of assignments to global variables. The parameter symbol
identifies the variable (as either a string name or a symbol identifier). cmd (which may be a string or a Proc
object) or block is executed whenever the variable is assigned. The block or Proc
object receives the variable’s new value as a parameter. Also see Kernel::untrace_var.
trace_var :$_, proc {|v| puts "$_ is now '#{v}'" } $_ = "hello" $_ = ' there'
produces:
$_ is now 'hello' $_ is now ' there'
Removes tracing for the specified command on the given global variable and returns nil
. If no command is specified, removes all tracing for that variable and returns an array containing the commands actually removed.
Returns the names of the current local variables.
fred = 1 for i in 1..10 # ... end local_variables #=> [:fred, :i]