- Quick start guide
- System requirements
- Installation guide
- Administrators guide
- Mobile networks
- User guide
- Developers guide
- SMS from SQL
- C# SMS API
- HTTP SMS API
- PHP SMS API
- VB.NET SMS API
- Programming APIs
- C# SMS tutorial
- VB SMS tutorial
- F# SMS tutorial
- Java SMS tutorial
- Node.js SMS tutorial
- Kotlin SMS tutorial
- C/Cpp SMS tutorial
- Delphi SMS tutorial
- PHP SMS tutorial
- Perl SMS tutorial
- Python SMS tutorial
- Python flask SMS tutorial
- Ruby SMS tutorial
- Ruby send sms
- Ruby multiple sms
- Ruby schedule sms
- Ruby receive sms
- Ruby delete sms
- Ruby sms Github
- Ruby send sms linux
- Tcl/Tk SMS tutorial
- Go SMS tutorial
- R SMS tutorial
- Scala SMS tutorial
- Objective C SMS tutorial
- Service providers
Ruby tutorial: Hello world
This tutorial helps you get started with Ruby. It explains what you need to write your first Ruby program. It starts with the basics: you will learn where you can find and download the tools needed, how to install these tools and it will take you all the way to building and runing your code. If you have never written a Ruby program before this is the place to start. We have created this article, so you can get started with Ruby, and move on to our sms examples. If you are already familiar with Ruby, you can jump directly to one of the following SMS projects.
Ruby sms examples:
Ruby send sms with the HTTP rest api (code sample)
Ruby send multiple sms with the HTTP rest api (code sample)
Ruby schedule sms with the HTTP rest api (code sample)
Ruby receive sms with the HTTP rest api (code sample)
Ruby delete sms with the HTTP rest api (code sample)
Download the latest Ruby sms api library from Github
What is Ruby
Ruby is a programming language. It is similar to a natural language, like English. It is used to talk to a computer. The major difference between a natural language and a programming language is that, programming languages have a more rigorous structure, to help the computer understand it better.
What is a Ruby Hello world program
The Ruby hello world program is the most simple program you can write. It simply prints out the sententce: Hello world on the computer screen. The Hello World program is the first program developers write in any programming language.
How to write your first program in Ruby
To write your first program in Ruby:
- Check prerequisites
- Setup Ruby
- Open Notepad
- Save the file with .rb file extension
- Write Hello World program in Ruby
- Run your Ruby Hello World program
- Check the output
- Handle the errors
Here is what you need to get started. To write your first computer program in Ruby, you need a Windows computer and example code presented below.
- Windows 10 computer
- Ozeki Hello World example project
You may download Ruby from the following URL: https://rubyinstaller.org/downloads/
To write your first Ruby program, you need to install Ruby. The following video shows you how this installation can be done.
Create your first Ruby program
After Ruby has been installed, you need to open the Notepad.
To get started with coding in Ruby, you must first open Notepad. Type "notepad" into the search bar on the bottom left (Figure 1). The first result will return the Notepad application. Click on it to open.
Click on File, then Save as... to save your file (Figure 2). This will open up a new window.
Name the file
Once you clicked Save as... , a new window opens. Here you can name your file and specify a location (Figure 3). Make sure it is saved as a .rb file. Click on the Save button to save your file to the selected directory.
Write your 'hello world' program in Ruby
The first program you write in any programming language is the 'Hello world' program. The sole aim of this program is to print the term 'Hello world' to the computer screen. In this example the program consists of two lines of code: The first line: puts "" prints the text.
puts "Hello world!"
Write the code
This piece of code has only one purpose. It displays the "Hello world!" message. In Ruby it only consists of one line. The puts command (short for put string) outputs text from a string data type. The text you wish to output will go after the puts command and inside of quotation marks (Figure 4).
Run the Ruby 'hello world' program
To run the hello world program, you need to press Enter.
Run the program
Start by opening up the Command Prompt. Change the directory to where your file is located. Now type in the name of the file (FirstRubyApp.rb) and hit enter (Figure 5). You can see that the "Hello World" message has appeared, indicating that the code ran successfully.
What happens if I make a mistake in Ruby
If you make a mistake, when you write your instructions in Ruby, you will get a Syntax error. The computer will highlight the line with error in red, and it will tell you why didn't it understand the instructions. To correct the mistake you need to go back to the text editor and modify the program. Programs say they "fix the error" when they correct mistakes.
What is syntax error in Ruby?
Syntax error means I don't understand. If you talk to somebody in English and he does not understand what you say, he will reply with "I don't understand". If you talk to a computer in Ruby and the computer does not understand what you say, he will reply with "Syntax error".
In the code below we will create a mistake intentionally by not putting a semicolon after the Hello World line. You will see, how the computer reacts, how we fix the error, and how we run the computer program successfully.
How to handle a syntax error in Ruby?
In the code below we will create a syntax error intentionally by not putting a semicolon after the Hello World line. You will see, how the computer reacts, how we fix the error, and how we run the computer program successfully.
Errors in Ruby
Now we are going to take a look at what happens when the code is not correct. Modify the code to make a mistake intentionally. Replace the "puts" command with "put". This will lead to an error when you run the program. The hello world message will not appear, but an error message gets displayed instead (Figure 6). This message is useful, because it tells you what type of error you have made. This way it is easier for the developer to find it and fix it.
Now that you have completed the five simple steps above, you have made your first step in becoming a VB.Net software developer. This program may seam simple, and it may not do much, but this is how great things start. The next step in your learning jurney will be creating an HTTP request.
- C# SMS tutorial: Hello world
- Visual Basic SMS tutorial: Hello world
- F# SMS tutorial: Hello world
- Java SMS tutorial: Hello world
- Node.js SMS tutorial: Hello world
- Kotlin SMS tutorial: Hello world
- C/C SMS tutorial: Hello world
- Delphi SMS tutorial: Hello world
- PHP SMS tutorial: Hello world
- Perl SMS tutorial: Hello world
- Python SMS tutorial: Hello world
- Python flask SMS tutorial: Hello world
- Tcl/Tk SMS tutorial: Hello world
- Go SMS tutorial: Hello world
- R SMS tutorial: Hello world
- Scala SMS tutorial: Hello world
- Objective C SMS tutorial: Hello world