The block passed to this method will be called just before running the RDoc
generator. It is allowed to modify RDoc::Task
attributes inside the block.
Convenience method for Shell::CommandProcessor.def_system_command
. Defines an instance method which will execute the given shell command. If the executable is not in Shell.default_system_path
, you must supply the path to it.
Shell.def_system_command('hostname') Shell.new.hostname # => localhost # How to use an executable that's not in the default path Shell.def_system_command('run_my_program', "~/hello") Shell.new.run_my_program # prints "Hello from a C program!"
Convenience method for Shell::CommandProcessor.undef_system_command
Returns true
if a local variable symbol
exists.
def foo a = 1 binding.local_variable_defined?(:a) #=> true binding.local_variable_defined?(:b) #=> false end
This method is the short version of the following code:
binding.eval("defined?(#{symbol}) == 'local-variable'")
The Kernel#require
from before RubyGems was loaded.
Calls block with two arguments, the item and its index, for each item in enum. Given arguments are passed through to each().
If no block is given, an enumerator is returned instead.
hash = Hash.new %w(cat dog wombat).each_with_index { |item, index| hash[item] = index } hash #=> {"cat"=>0, "dog"=>1, "wombat"=>2}
Returns the last win32 Error
of the current executing Thread
or nil if none
Sets the last win32 Error
of the current executing Thread
to error
Return internal class of obj.
obj can be an instance of InternalObjectWrapper
.
Note that you should not use this method in your application.
obj can be an instance of InternalObjectWrapper
.
Note that you should not use this method in your application.
Specifies VI editing mode. See the manual of GNU Readline
for details of VI editing mode.
Raises NotImplementedError
if the using readline library does not support.
Returns true if vi mode is active. Returns false if not.
Raises NotImplementedError
if the using readline library does not support.
Specifies a Proc
object proc
to call after the first prompt has been printed and just before readline starts reading input characters.
See GNU Readline’s rl_pre_input_hook variable.
Raises ArgumentError
if proc
does not respond to the call method.
Raises NotImplementedError
if the using readline library does not support.
Returns a Proc
object proc
to call after the first prompt has been printed and just before readline starts reading input characters. The default is nil.
Raises NotImplementedError
if the using readline library does not support.
Returns information about the most recent garbage collection.
Verify internal consistency.
This method is implementation specific. Now this method checks generational consistency if RGenGC is supported.
Returns the size of memory allocated by malloc().
Only available if ruby was built with CALC_EXACT_MALLOC_SIZE
.
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.
Shortcut for defining multiple delegator methods, but with no provision for using a different name. The following two code samples have the same effect:
def_delegators :@records, :size, :<<, :map def_delegator :@records, :size def_delegator :@records, :<< def_delegator :@records, :map
Define method
as delegator instance method with an optional alias name ali
. Method
calls to ali
will be delegated to accessor.method
.
class MyQueue extend Forwardable attr_reader :queue def initialize @queue = [] end def_delegator :@queue, :push, :mypush end q = MyQueue.new q.mypush 42 q.queue #=> [42] q.push 23 #=> NoMethodError
Shortcut for defining multiple delegator methods, but with no provision for using a different name. The following two code samples have the same effect:
def_delegators :@records, :size, :<<, :map def_delegator :@records, :size def_delegator :@records, :<< def_delegator :@records, :map
Defines a method method which delegates to accessor (i.e. it calls the method of the same name in accessor). If new_name is provided, it is used as the name for the delegate method.