Don't forget to bookmark us! Press CTRL+D / CMD + D  |  

Ruby Language Cheat Sheet

We provide you will all the mostly used Ruby modules and corresponding function and feature list. You can click on the feature and see more details about the feature with example code. We hope you will enjoy the cheat sheet and developer hints very much.

No result found
BasicObject

BasicObject is the parent class of all classes in Ruby. It's an explicit blank class.

BasicObject can be used for creating object hierarchies independent of Ruby's object hierarchy, proxy objects like the Delegator class, or other uses where namespace pollution from Ruby's methods and classes must be avoided.


See more
Class

Classes in Ruby are first-class objects---each is an instance of class Class.

Typically, you create a new class by using:


See more
ENV

ENV is a hash-like accessor for environment variables.

When you get the value for a name in ENV, the value is retrieved from among the current environment variables.

When you create or set a name-value pair in ENV, the name and value are immediately set in the environment variables.

When you delete a name-value pair in ENV, it is immediately deleted from the environment variables.

A String.

An object that responds to #to_str by returning a String, in which case that String will be used as the name or value.

May not be the empty string:

May not contain character "=":

May not be a non-String that does not respond to #to_str:

May not contain the NUL character "\0":

May not have an ASCII-incompatible encoding such as UTF-16LE or ISO-2022-JP:

A Hash returned by an ENV method.

An Enumerator returned by an ENV method.

An Array returned by ::keys, ::values, or ::to_a.

The String returned by ::inspect.

The Array returned by ::shift.

The name returned by ::key.

::replace replaces ENV with a new collection of entries.

::clear empties ENV.


See more
File

A File is an abstraction of any file object accessible by the program and is closely associated with class IO. File includes the methods of module FileTest as class methods, allowing you to write (for example) File.exist?("foo").

In the description of File methods, permission bits are a platform-specific set of bits that indicate permissions of a file. On Unix-based systems, permissions are viewed as a set of three octets, for the owner, the group, and the rest of the world. For each of these entities, permissions may be set to read, write, or execute the file:


See more
IO

The IO class is the basis for all input and output in Ruby. An I/O stream may be duplexed (that is, bidirectional), and so may use more than one native operating system stream.

Many of the examples in this section use the File class, the only standard subclass of IO. The two classes are closely associated. Like the File class, the Socket library subclasses from IO (such as TCPSocket or UDPSocket).

A plain string represents a filename suitable for the underlying operating system.

A string starting with "|" indicates a subprocess. The remainder of the string following the "|" is invoked as a process with appropriate input/output channels connected to it.

A string equal to "|-" will create another Ruby instance as a subprocess.

IO::console

IO#raw

IO#raw!

IO#cooked

IO#cooked!

IO#getch

IO#echo=

IO#echo?

IO#noecho

IO#winsize

IO#winsize=

IO#iflush

IO#ioflush

IO#oflush


See more
Kernel

The Kernel module is included by class Object, so its methods are available in every Ruby object.

The Kernel instance methods are documented in class Object while the module methods are documented here. These methods are called without a receiver and thus can be called in functional form:


See more