Returns the called name of the current method as a Symbol
. If called outside of a method, it returns nil
.
Invokes Posix system call syscall(2), which calls a specified function.
Calls the operating system function identified by integer_callno
; returns the result of the function or raises SystemCallError
if it failed. The effect of the call is platform-dependent. The arguments and returned value are platform-dependent.
For each of arguments
: if it is an integer, it is passed directly; if it is a string, it is interpreted as a binary sequence of bytes. There may be as many as nine such arguments.
Arguments integer_callno
and argument
, as well as the returned value, are platform-dependent.
Note: Method
syscall
is essentially unsafe and unportable. The DL (Fiddle
) library is preferred for safer and a bit more portable programming.
Not implemented on all platforms.
Returns the current execution stack—an array containing strings in the form file:line
or file:line: in `method'
.
The optional start parameter determines the number of initial stack entries to omit from the top of the stack.
A second optional length
parameter can be used to limit how many entries are returned from the stack.
Returns nil
if start is greater than the size of current execution stack.
Optionally you can pass a range, which will return an array containing the entries within the specified range.
def a(skip) caller(skip) end def b(skip) a(skip) end def c(skip) b(skip) end c(0) #=> ["prog:2:in `a'", "prog:5:in `b'", "prog:8:in `c'", "prog:10:in `<main>'"] c(1) #=> ["prog:5:in `b'", "prog:8:in `c'", "prog:11:in `<main>'"] c(2) #=> ["prog:8:in `c'", "prog:12:in `<main>'"] c(3) #=> ["prog:13:in `<main>'"] c(4) #=> [] c(5) #=> nil
Returns whether every element meets a given criterion.
If self
has no element, returns true
and argument or block are not used.
With no argument and no block, returns whether every element is truthy:
(1..4).all? # => true %w[a b c d].all? # => true [1, 2, nil].all? # => false ['a','b', false].all? # => false [].all? # => true
With argument pattern
and no block, returns whether for each element element
, pattern === element
:
(1..4).all?(Integer) # => true (1..4).all?(Numeric) # => true (1..4).all?(Float) # => false %w[bar baz bat bam].all?(/ba/) # => true %w[bar baz bat bam].all?(/bar/) # => false %w[bar baz bat bam].all?('ba') # => false {foo: 0, bar: 1, baz: 2}.all?(Array) # => true {foo: 0, bar: 1, baz: 2}.all?(Hash) # => false [].all?(Integer) # => true
With a block given, returns whether the block returns a truthy value for every element:
(1..4).all? {|element| element < 5 } # => true (1..4).all? {|element| element < 4 } # => false {foo: 0, bar: 1, baz: 2}.all? {|key, value| value < 3 } # => true {foo: 0, bar: 1, baz: 2}.all? {|key, value| value < 2 } # => false
Allocate size
bytes of memory and return the integer memory address for the allocated memory.
Change the size of the memory allocated at the memory location addr
to size
bytes. Returns the memory address of the reallocated memory, which may be different than the address passed in.
Really verbose mode gives you extra output.
Call hooks on installed gems
Implementation for Specification#validate_metadata
Uninstalls gem spec
Starts tracing object allocations.
Returns true
if the named file is writable by the real user and group id of this process. See access(3).
Note that some OS-level security features may cause this to return true even though the file is not writable by the real user/group.
Returns true
if the named file is executable by the real user and group id of this process. See access(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 real user/group.
Return true if the caused method was called as private.
Returns true
if the arguments define a valid ordinal date, false
otherwise:
Date.valid_ordinal?(2001, 34) # => true Date.valid_ordinal?(2001, 366) # => false
See argument start.
Related: Date.jd
, Date.ordinal
.
Returns true
if the arguments define a valid commercial date, false
otherwise:
Date.valid_commercial?(2001, 5, 6) # => true Date.valid_commercial?(2001, 5, 8) # => false
See Date.commercial
.
See argument start.
Related: Date.jd
, Date.commercial
.
Returns an array of all symbols currently in Ruby’s symbol table:
Symbol.all_symbols.size # => 9334 Symbol.all_symbols.take(3) # => [:!, :"\"", :"#"]