You'll need to install a Ruby distribution for Windows in your system rubyinstaller.org in the downloads area (This is a self-contained Windows-based installer that includes the Ruby language, an execution environment, important documentation, and more.)
Now execute the installer and proceed with the installation of Ruby for windows as you usually do with any installer.
However, in the Installation Destination and Optional tasks do not forget to check all three options in order to use ruby easily on your computer.
Proceed to install and wait till the wizard finishes.
You can execute Ruby code now in your computer, so let's write some code. Before continue, check in your command prompt (cmd.exe) if you've succesfully installed ruby executing the following command on it:ruby -v
The environment variable ruby should be available everywhere in your console, and the previous command should output something similar (with the version of your distribution) in the console:
Now get started with your Hello World in Ruby, create a file named hello.rb wherever you want. In this case we are going to create a folder in the Desktop with the name ruby and we are going to save the hello.rb file inside.
The previously created file will contain the following code:puts 'Hello world ! The date and time now is : ' + Time.now.strftime("%d/%m/%Y %H:%M")
To execute a ruby file, you only need to do "ruby path-to-the-file-and-filename" and you're ready to go. As mentioned previously, in this example the file will be located in the ruby folder in the desktop, so you can navigate to the folder using console commands and then execute the file:cd C:\Users\sdkca\Desktop\ruby ruby hello.rb
Or just provide the absolute path of the file as second parameter:ruby C:\Users\sdkca\Desktop\ruby\hello.rb
And the output of the console will be: