Returns true
iff the current severity level allows for the printing of FATAL
messages.
Invokes the block, setting the block’s parameters to the values in params using something close to method calling semantics. Returns the value of the last expression evaluated in the block.
a_proc = Proc.new {|scalar, *values| values.map {|value| value*scalar } } a_proc.call(9, 1, 2, 3) #=> [9, 18, 27] a_proc[9, 1, 2, 3] #=> [9, 18, 27] a_proc.(9, 1, 2, 3) #=> [9, 18, 27] a_proc.yield(9, 1, 2, 3) #=> [9, 18, 27]
Note that prc.()
invokes prc.call()
with the parameters given. It’s syntactic sugar to hide “call”.
For procs created using lambda
or ->()
an error is generated if the wrong number of parameters are passed to the proc. For procs created using Proc.new
or Kernel.proc
, extra parameters are silently discarded and missing parameters are set to nil
.
a_proc = proc {|a,b| [a,b] } a_proc.call(1) #=> [1, nil] a_proc = lambda {|a,b| [a,b] } a_proc.call(1) # ArgumentError: wrong number of arguments (given 1, expected 2)
See also Proc#lambda?
.
Invokes the meth with the specified arguments, returning the method’s return value.
m = 12.method("+") m.call(3) #=> 15 m.call(20) #=> 32
Generates a Continuation
object, which it passes to the associated block. You need to require 'continuation'
before using this method. Performing a cont.call
will cause the callcc
to return (as will falling through the end of the block). The value returned by the callcc
is the value of the block, or the value passed to cont.call
. See class Continuation
for more details. Also see Kernel#throw
for an alternative mechanism for unwinding a call stack.
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.
Creates an installer for spec
that will install into gem_home
. If user
is true a user-install will be performed.