Returns the called name of the current method as a Symbol
. If called outside of a method, it returns nil
.
Calls the operating system function identified by num and returns the result of the function or raises SystemCallError
if it failed.
Arguments for the function can follow num. They must be either String
objects or Integer
objects. A String
object is passed as a pointer to the byte sequence. An Integer
object is passed as an integer whose bit size is same as a pointer. Up to nine parameters may be passed.
The function identified by num is system dependent. On some Unix systems, the numbers may be obtained from a header file called syscall.h
.
syscall 4, 1, "hello\n", 6 # '4' is write(2) on our box
produces:
hello
Calling syscall
on a platform which does not have any way to an arbitrary system function just fails with NotImplementedError
.
Note: syscall
is essentially unsafe and unportable. Feel free to shoot your foot. The DL (Fiddle
) library is preferred for safer and a bit more portable programming.
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
Passes each element of the collection to the given block. The method returns true
if the block never returns false
or nil
. If the block is not given, Ruby adds an implicit block of { |obj| obj }
which will cause all?
to return true
when none of the collection members are false
or nil
.
If instead a pattern is supplied, the method returns whether pattern === element
for every collection member.
%w[ant bear cat].all? { |word| word.length >= 3 } #=> true %w[ant bear cat].all? { |word| word.length >= 4 } #=> false %w[ant bear cat].all?(/t/) #=> false [1, 2i, 3.14].all?(Numeric) #=> true [nil, true, 99].all? #=> false [].all? #=> true
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.
Convenience method for Shell::CommandProcessor.install_system_commands. Defines instance methods representing all the executable files found in Shell.default_system_path
, with the given prefix prepended to their names.
Shell.install_system_commands Shell.new.sys_echo("hello") # => hello
Set
the default id conversion object.
This is expected to be an instance such as DRb::DRbIdConv
that responds to to_id
and to_obj
that can convert objects to and from DRb
references.
See DRbServer#default_id_conv.
Set
the default id conversion object.
This is expected to be an instance such as DRb::DRbIdConv
that responds to to_id
and to_obj
that can convert objects to and from DRb
references.
See DRbServer#default_id_conv.
Really verbose mode gives you extra output.
Install generated indices into the destination directory.
Return an Array of Specifications contained within the gem_home
we’ll be installing into.
Creates an installer for spec
that will install into gem_home
. If user
is true a user-install will be performed.
Builds and installs the Gem::Specification
spec
Uninstalls the Gem::Specification
spec
Install the provided specs
Uninstalls gem spec