In Ruby, everything is an object. More precisely, everything in Ruby is a fully functional object. So, in Ruby, the number 4, the fixed-point number 3.14, and the string "Hi" are all objects. Obviously, they are a bit "special" because you don't have to use the new method to create them. Instead, you use a form such as "literal 4" to create an instance of an object representing the number 4.
However, for the vast majority of people, it is useful to first understand the "standard" type provided by the language when learning a new programming language. So, in this section, we'll start with numeric types, string types, Boolean types, and other basic ruby data types.
Number Type
In essence, the numbers in Ruby are divided into integers and floating-point number two categories. Where integers are further subdivided into "general size" integers and large integers. Because everything is an object in Ruby, integers and floating-point numbers are defined by class (see Figure 1). As you see in Figure 1, numeric is the base class for all numeric types, and float and integer classes are subclasses of numeric. Both Fixnum and bignum are subtypes of integers-they define the "General size" integer and the large integer respectively.
Figure 1. Ruby's numeric type class inheritance diagram
Literal is used to describe instances of these classes. The following code in the interactive Ruby Shell (IRB) shows the literal instance of Float,fixnum and Bignum. Note that a method call can be made on the literal (in this case, the class method).
IRB (main): 001:0>3.class
=>fixnum
IRB (main): 002:0>3.4.class
=>float
IRB (main): 003:0 >10000000000000000000.class
=>bignum