How To Install Ruby?
Ruby was influenced by different languages such as Perl, Smalltalk, Lisp according to its creator, Yukihiro “Matz” Matsumoto in from Japan. The syntax of Ruby is similar to Perl, while the interpretation is similar to Smalltalk but it differs considerably from Python. It supports functional and object-oriented programming. It has a dynamic type system and memory management can be done without any intervention. It is a dynamic and general purpose programming language. Keywords are used to define Class and Methods, whereas code blocks can be both defined by keywords or braces. When the sigil is used, it changes the semantics of the scope of the variable. Defining the functions/variables outside classes and making them part of the Object is known as Procedural Programming. When everything is an object or it has anonymous functions, closures, and continuations with each statement having a value, and functions return the last evaluation then it is referred to Object Oriented Programming.
Features of Ruby
- Exception handling and Operator overloading can be done.
- Thoroughly object-oriented with inheritance and metaclasses.
- Default arguments.
- The levels of variable scope are denoted by sigils such global, class, instance, and local.
- RubyGems are used as Centralized package management.
- REPL is an Interactive Ruby Shell.
- Support for Unicode and multiple character encodings.
- YAML, JSON, and XML are the standard library modules available.
The libraries in a self-contained setup are termed “gem”. Each gem consists of:
- Gem specification (Gemspec)
RubyGems is a package handler that provides a standard format for distributing Ruby programs. The installation of gems is handled easily through this. RubyGems is integrated with Ruby run-time loader. This loads the installed gems from the library folders. Gems work with ruby designed for a certain platform based on CPU architecture, OS of the system and the Version. Every gem contains three important things
Steps to Install Ruby
In Debian GNU/Linux and Ubuntu we can install Ruby as shown below:
$ sudo apt-get install ruby-full
The ruby-full package provides the old stable release, on Debian and Ubuntu.
Using the yum package manager for RHEL, CentOS and Fedora.
$ sudo yum install ruby
The Version installed through this is the latest that would be available at that time of release.
4.6 (3,144 ratings)
Updating Ruby using Installers
A newer version can be installed using third-party installers if the already installed version of Ruby is expired. It is possible to install multiple versions of Ruby on the same system. There are dedicated tools that can help to switch between the different versions. Separate Third-Party installers are not necessary when we use RVM (Ruby-Version-Manager).
Ruby-build is a plugin for rbenv. Different versions of Ruby can be compiled and installed with this. Available for:
- UNIX-like operating systems
Different versions of Ruby can be compiled and installed into arbitrary directories using the Ruby-install. In MacOs and Linux machines, Chruby is a tool which is provided to toggle between different Ruby versions installed the same machine.
RubyInstaller provides pretty much a full setup for a complete Ruby development environment On Windows.
How To Install Ruby on Windows
- Open -> https://rubyinstaller.org/
- Anyone without prior knowledge about Ruby can consider the option to have a deep understanding.
- You can go through the basics of Ruby Installation and the Uses of Ruby from the given link “Is RubyInstaller for you?”
- The Ruby+Devkit (Version) provided is the most stabilized and the completely tested version of Ruby that is available for a download.
- Once the download is complete, open the installer by Double-Clicking. The following Windows appears:
- Click on “I accept the License” and Next.
- In the next dialogue box, you can change the Target Path of Ruby installation.
You can move the mouse pointer over the Check-Boxes to have a brief explanation of the options.
- The UTF-8 option is used to set the environment variable.
- Associate the .rb and .rbw files will allow you to run Ruby on double-click or simply typing the command name on the shell.
- Add Ruby executables allows you to install Ruby from everywhere. This may affect the existing Ruby installations.
- Click on Install.
- Check the box if you wish to install MYS2 development chain along with Ruby. Click on Next.
- Once the installation is complete click on Finish.
- You are ready to Go.
Ruby On Mac-OS:
MacOS comes pre-installed with Ruby. You can run ruby -v on your terminal, it will point to the pre-installed version.
Introduction to Ruby on Rails
Ruby on Rails is a framework written in Ruby to develop server-side web applications. Rails needed a language to embed the dynamic web page into HTML code. At that time the creator of rails considered Ruby as a better option than other languages. The model–view–controller (MVC) pattern is employed to organize application programming. Ruby on Rails is most commonly connected to the Internet through some front-end web server.
A database and a Ruby file are mapped to a table in the Ruby on Rails framework. This is referred to as a model. Developers are free to ignore the naming convention and choose different names for the tables, models and the associated files. But the best practice is to name as follows: A file ‘user.rb’ in the app/models directory can be associated with the table ‘users’ in the database.
The server-side component of Rails is known as Controller. It determines which file to be delivered to the external requests from the web server. The search function needs a query to find the data matching the search. The controller then passes some subset of the data to the corresponding view to create an HTML document containing a table with one row per data. A controller renders one or multiple actions which is basically a block that specifies how to respond to an external request.
During Run-Time, an Erb file is evaluated and converted to HTML. This is achieved using View. Rails include tools that make the developers’ task easier to construct models and views for a basic website.
This has been a guide on how to install Ruby. Here we have discussed the Instructions and different steps to install Ruby. You may also look at the following article to learn more –