Looks up the first IP address for name
.
Looks up all IP address for name
.
Looks up the first IP address for name
.
Looks up all IP address for name
.
Replaces the elements with ones returned by collect().
Sends the given signal
to the given job
Basically the same as ::new
. However, if class Thread
is subclassed, then calling start
in that subclass will not invoke the subclass’s initialize
method.
Causes the given thread
to exit, see also Thread::exit
.
count = 0 a = Thread.new { loop { count += 1 } } sleep(0.1) #=> 0 Thread.kill(a) #=> #<Thread:0x401b3d30 dead> count #=> 93947 a.alive? #=> false
Waits for thr
to complete, using join
, and returns its value or raises the exception which terminated the thread.
a = Thread.new { 2 + 2 } a.value #=> 4 b = Thread.new { raise 'something went wrong' } b.value #=> RuntimeError: something went wrong
Terminates thr
and schedules another thread to be run.
If this thread is already marked to be killed, exit
returns the Thread
.
If this is the main thread, or the last thread, exits the process.
Returns the status of thr
.
"sleep"
Returned if this thread is sleeping or waiting on I/O
"run"
When this thread is executing
"aborting"
If this thread is aborting
false
When this thread is terminated normally
nil
If terminated with an exception.
a = Thread.new { raise("die now") } b = Thread.new { Thread.stop } c = Thread.new { Thread.exit } d = Thread.new { sleep } d.kill #=> #<Thread:0x401b3678 aborting> a.status #=> nil b.status #=> "sleep" c.status #=> false d.status #=> "aborting" Thread.current.status #=> "run"
Returns true
if thr
is running or sleeping.
thr = Thread.new { } thr.join #=> #<Thread:0x401b3fb0 dead> Thread.current.alive? #=> true thr.alive? #=> false
Evaluates the Ruby expression(s) in string, in the binding’s context. If the optional filename and lineno parameters are present, they will be used when reporting syntax errors.
def get_binding(param) binding end b = get_binding("hello") b.eval("param") #=> "hello"
Return the tag object which was called for.
Return the return value which was called for.
Returns internal information of TracePoint
.
The contents of the returned value are implementation specific. It may be changed in future.
This method is only for debugging TracePoint
itself.
See also BigDecimal.new
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
.
Evaluates the Ruby expression(s) in string. If binding is given, which must be a Binding
object, the evaluation is performed in its context. If the optional filename and lineno parameters are present, they will be used when reporting syntax errors.
def get_binding(str) return binding end str = "hello" eval "str + ' Fred'" #=> "hello Fred" eval "str + ' Fred'", get_binding("bye") #=> "bye Fred"
Returns a new array with the results of running block once for every element in enum.
If no block is given, an enumerator is returned instead.
(1..4).map { |i| i*i } #=> [1, 4, 9, 16] (1..4).collect { "cat" } #=> ["cat", "cat", "cat", "cat"]
Returns first n elements from enum.
a = [1, 2, 3, 4, 5, 0] a.take(3) #=> [1, 2, 3] a.take(30) #=> [1, 2, 3, 4, 5, 0]
Computes the arctangent of decimal
to the specified number of digits of precision, numeric
.
If decimal
is NaN, returns NaN.
BigMath.atan(BigDecimal.new('-1'), 16).to_s #=> "-0.785398163397448309615660845819878471907514682065E0"
Determines the equality of two numbers by comparing to zero, or using the epsilon value
Enables coverage measurement.
Convert self
to locale encoding