Results for: "tally"

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, returning the terminated 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"

See also the instance methods alive? and stop?

Returns true if thr is running or sleeping.

thr = Thread.new { }
thr.join                #=> #<Thread:0x401b3fb0 dead>
Thread.current.alive?   #=> true
thr.alive?              #=> false

See also stop? and status.

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.

Return the tag object which was called for.

Return the return value which was called for.

Yields self to the block, and then returns self. The primary purpose of this method is to “tap into” a method chain, in order to perform operations on intermediate results within the chain.

(1..10)                  .tap {|x| puts "original: #{x}" }
  .to_a                  .tap {|x| puts "array:    #{x}" }
  .select {|x| x.even? } .tap {|x| puts "evens:    #{x}" }
  .map {|x| x*x }        .tap {|x| puts "squares:  #{x}" }

Returns x/y or arg as a Rational.

Rational(2, 3)   #=> (2/3)
Rational(5)      #=> (5/1)
Rational(0.5)    #=> (1/2)
Rational(0.3)    #=> (5404319552844595/18014398509481984)

Rational("2/3")  #=> (2/3)
Rational("0.3")  #=> (3/10)

Rational("10 cents")  #=> ArgumentError
Rational(nil)         #=> TypeError
Rational(1, nil)      #=> TypeError

Rational("10 cents", exception: false)  #=> nil

Syntax of the 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 also 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 an array of objects returned by the block.

With a block given, calls the block with successive elements; returns an array of the objects returned by the block:

(0..4).map {|i| i*i }                               # => [0, 1, 4, 9, 16]
{foo: 0, bar: 1, baz: 2}.map {|key, value| value*2} # => [0, 2, 4]

With no block given, returns an Enumerator.

For non-negative integer n, returns the first n elements:

r = (1..4)
r.take(2) # => [1, 2]
r.take(0) # => []

h = {foo: 0, bar: 1, baz: 2, bat: 3}
h.take(2) # => [[:foo, 0], [:bar, 1]]

Enables the coverage measurement. See the documentation of Coverage class in detail. This is equivalent to Coverage.setup and Coverage.resume.

Returns the state of the coverage measurement.

Returns true if the named file is writable by the effective user and group id of this process. See eaccess(3).

Note that some OS-level security features may cause this to return true even though the file is not writable by the effective user/group.

Returns true if the named file is executable by the effective user and group id of this process. See eaccess(3).

Windows does not support execute permissions separately from read permissions. On Windows, a file is only considered executable if it ends in .bat, .cmd, .com, or .exe.

Note that some OS-level security features may cause this to return true even though the file is not executable by the effective user/group.

Returns true if the named files are identical.

file_1 and file_2 can be an IO object.

open("a", "w") {}
p File.identical?("a", "a")      #=> true
p File.identical?("a", "./a")    #=> true
File.link("a", "b")
p File.identical?("a", "b")      #=> true
File.symlink("a", "c")
p File.identical?("a", "c")      #=> true
open("d", "w") {}
p File.identical?("a", "d")      #=> false

Initiates garbage collection, even if manually disabled.

The full_mark keyword argument determines whether or not to perform a major garbage collection cycle. When set to true, a major garbage collection cycle is ran, meaning all objects are marked. When set to false, a minor garbage collection cycle is ran, meaning only young objects are marked.

The immediate_mark keyword argument determines whether or not to perform incremental marking. When set to true, marking is completed during the call to this method. When set to false, marking is performed in steps that is interleaved with future Ruby code execution, so marking might not be completed during this method call. Note that if full_mark is false then marking will always be immediate, regardless of the value of immediate_mark.

The immediate_sweep keyword argument determines whether or not to defer sweeping (using lazy sweep). When set to false, sweeping is performed in steps that is interleaved with future Ruby code execution, so sweeping might not be completed during this method call. When set to true, sweeping is completed during the call to this method.

Note: These keyword arguments are implementation and version dependent. They are not guaranteed to be future-compatible, and may be ignored if the underlying implementation does not support them.

Returns a Hash containing information about the GC.

The contents of the hash are implementation specific and may change in the future without notice.

The hash includes information about internal statistics about GC such as:

count

The total number of garbage collections ran since application start (count includes both minor and major garbage collections)

time

The total time spent in garbage collections (in milliseconds)

heap_allocated_pages

The total number of :heap_eden_pages + :heap_tomb_pages

heap_sorted_length

The number of pages that can fit into the buffer that holds references to all pages

heap_allocatable_pages

The total number of pages the application could allocate without additional GC

heap_available_slots

The total number of slots in all :heap_allocated_pages

heap_live_slots

The total number of slots which contain live objects

heap_free_slots

The total number of slots which do not contain live objects

heap_final_slots

The total number of slots with pending finalizers to be run

heap_marked_slots

The total number of objects marked in the last GC

heap_eden_pages

The total number of pages which contain at least one live slot

heap_tomb_pages

The total number of pages which do not contain any live slots

total_allocated_pages

The cumulative number of pages allocated since application start

total_freed_pages

The cumulative number of pages freed since application start

total_allocated_objects

The cumulative number of objects allocated since application start

total_freed_objects

The cumulative number of objects freed since application start

malloc_increase_bytes

Amount of memory allocated on the heap for objects. Decreased by any GC

malloc_increase_bytes_limit

When :malloc_increase_bytes crosses this limit, GC is triggered

minor_gc_count

The total number of minor garbage collections run since process start

major_gc_count

The total number of major garbage collections run since process start

compact_count

The total number of compactions run since process start

read_barrier_faults

The total number of times the read barrier was triggered during compaction

total_moved_objects

The total number of objects compaction has moved

remembered_wb_unprotected_objects

The total number of objects without write barriers

remembered_wb_unprotected_objects_limit

When :remembered_wb_unprotected_objects crosses this limit, major GC is triggered

old_objects

Number of live, old objects which have survived at least 3 garbage collections

old_objects_limit

When :old_objects crosses this limit, major GC is triggered

oldmalloc_increase_bytes

Amount of memory allocated on the heap for objects. Decreased by major GC

oldmalloc_increase_bytes_limit

When :old_malloc_increase_bytes crosses this limit, major GC is triggered

If the optional argument, hash, is given, it is overwritten and returned. This is intended to avoid probe effect.

This method is only expected to work on CRuby.

Returns the elapsed real time used to execute the given block.

Returns the elapsed real time used to execute the given block.

No documentation available
No documentation available
Search took: 5ms  ·  Total Results: 1359