The super class of all the Ruby class hierarchy, except for
Kernel
and
Nil
.
Kernel
self == other
Checks if two objects are same. The default
definition in the Kernel
class checks by object ID. It
should be redefined in subclasses according to the characteristic of
the class.
clone
dup
Returns the copy of the object. For cloned object,
obj == obj.clone
is always true, though
obj.equal?(obj.clone)
is false most of the time.
eql?(other)
Checks if two objects are same. This method is used
by Hash
to compare whether two
keys are same. When this method is redefined, the hash
method should be updated.
The default definition of the method eql?
is
like blow:
def eql?(other) self == other end
equal?(other)
Checks if two objects have same object ID. This method should not be redefined in the subclass.
self === other
This method is used to compare in case
.
The default definitions is `==
'.
extend(module...)
Extends self
by adding methods defined in
modules as singleton-methods.
hash
Returns the integer hash value of the object. It is used in the
Hash
class to calculate the
holding place of an object. The hash value of two objects must be
same, where these two objects are equal by using eql?
operator. So, whenever you redefine the definition of the
eql?
operator in any class, don't forget to redefine
hash
method according to the definition.
id
Returns the unique integer value for each object.
inspect
Returns the human-readable string representation of the receiver.
initialize(...)
The initialize method for the user-defined classes. This method will
be called from Class#new
to
initialize the newly created object.
The default behavior is to do nothing. It is assumed that this method
will be redefined in the subclasses. The argument to
Class#new
will be passed to
the initialize
instance_of?(class)
Returns TRUE, if self
is an instance of the specified
class. It is always true, when
obj.kind_of?(c)
is true.
kind_of?(class)
is_a?(class)
Returns TRUE, if self
is an instance of the specified
class, or its subclass.
method_missing(msg_id, ...)
Will be called when the specified method is not defined for the receiver. The first argument, msg_id is the method name as a symbol. The second and later arguments are the arguments given to the undefined method, if any.
nil?
Checks whether the receiver is nil
or not.
respond_to?(mesg[,priv])
Returns true if the receiver has the public method named mesg. Mesg must be the symbol fixnum or the string. It returns true for private methods, if the optional argument priv given, and its value is true,
type
Returns the name of the receiver's class.
send(symbol[, args...])
calls the method specified by the symbol, with args.
to_s
Returns the string representation of the self
.
This method is used internally by
print
and
sprintf
.
to_a
Converts the self
into an array. Returns an array of 1
element contains self
for classes would not be converted
into an array naturally.