Website hosting service by Active-Venture.com
 

 Back to Index

prev - up - next - index

Object

The super class of all the Ruby class hierarchy.

SuperClass:

Kernel

Methods:

self == other

Checks if two objects are equal. 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.

the dup method is defined as:

def dup
  self.clone
end

clone and dup copy the receiver, but they do not copy the objects pointed by the receiver (i.e shallow copy).

display([port])

Prints self to the port. The port's default value is $>.

def display(out=$>)
  out.print self
end
public :display
eql?(other)

Checks if two objects are equal. 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

Method for old style match like obj =~ /RE/. The default definitions is `=='.

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 equal, 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

the method named initialize automatically falls under private visibility.

instance_eval(expr)
instance_eval{...}

Evaluates the expr string in the object context. If block supplied for the method, the block is evaluated under the receiver's context. This allows to avoid compiling the string everytime.

In instance_eval's context, self is bound to the object, so that instance variables and methods of the receiver are accessed.

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.

instance_variables()

Returns the array of self's instance variable names.

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.

methods

Returns the array of the public method names which defined in the receiver.

nil?

Checks whether the receiver is nil or not.

private_methods

Returns the array of the private method names which defined in the receiver.

remove_instance_variable(name)

Removes specified instance variable from the object. It does not raise any exception even if the object does not have named instance variable.

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,

send(symbol[, args...])

calls the method specified by the symbol, with args.

singleton_method_added(id)

Will be called when the singleton method defined for the receiver.

singleton_methods

Returns the array of the singleton method names which defined in the receiver.

taint

Turns on `taint mark' of the object.

tainted?

Returns true if the string is `tainted'.

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.

type

Returns the receiver's class.

untaint

Turns off `taint mark' of the object. Programmers should be responsible for the security issue caused by removing the taint mark. The mark can't be removed if the security level ($SAFE) is greater than or equals to level 3.


prev - up - next - index

matz@netlab.co.jp

 

  

 

 

2002-2004 Active-Venture.com Website Hosting Service

 
Buy domain name at only $5.95/yr with comprehensive domain hosting services. Domain registration and domain search service from $5.95 Cheap domain name registration and domain transfer service
 

Disclaimer: This documentation is provided only for the benefits of our website hosting customers.
For authoritative source of the documentation, please refer to http://www.ruby-doc.org/docs/