Author: admin
-
Creating Self-Contained Ruby
Putting Ruby code in a file is obviously far more convenient and practical than using multiple -e command-line options. However, suppose we want to go a step further and be able to run a Ruby-based program by typing the file name containing the code rather than the ruby command. On Linux or UNIX, this is…
-
Executing Ruby File from Terminal
We will be creating a ruby file in VSCode with the name ‘SimpleExample.rb’. SimpleExample.rb: You can also try this code with Online Ruby Compiler Run Code We will now execute the ruby file from the terminal using the command “ruby <filename>”.
-
Interactive Execution of Ruby
Ruby is an interpreted programming language. This basically means that Ruby source code is not pre-compiled like it is with languages like C or C++, but rather is compiled and executed at run time. One advantage of being an interpreted language is that we can type Ruby code directly into the interpreter and have it…
-
Executing Ruby from the Command Line
Ruby allows users to run lines of code as command-line options to the ruby tool. The ‘-e’ command line flag is used to accomplish this. Let’s run ‘Hello Ninjas! Let’s learn Ruby.’. Example: You can also try this code with Online Ruby Compiler Run Code Output: Though this ‘-e’ flag only allows a single line of…
-
Basic Ruby Example
Ruby is not only a flexible scripting language in terms of syntax, but it is also extremely flexible in terms of how scripts can be executed. In this section, we’ll look at some simple Ruby examples to learn Ruby before diving into the various ways Ruby code can be executed. The most basic example we…
-
I can’t understand Ruby even after reading the manual!
The syntax of Ruby has been fairly stable since Ruby 1.0, but new features are added every now and then. So, the books and the online documentation can get behind. If you have a problem, feel free to ask in the mailing list (see the Mailing Lists page). Generally you’ll get timely answers from Matz himself,…
-
How can I annotate Ruby code with its results?
People commonly annotate Ruby code by showing the results of executing each statement as a comment attached to that statement. For example, in the following code, we show that the assignment generates the string “Billy Bob”, and then the result of extracting some substrings. Emacs and vim users can integrate this with their editing environments,…
-
Which is correct, “Ruby” or “ruby”?
Officially, the language is called “Ruby”. On most systems, it is invoked using the command ruby. It’s OK to use “ruby” instead of “Ruby”. Please don’t use “RUBY” as the language name. Originally, or historically, it was called “ruby”.
-
How can I thread the mailing list in mutt?
This section or parts of it might be out-dated or in need of confirmation. For some of the Ruby mailing lists, the mailing list software adds a prefix to the subject lines, for example ruby-core:1234. This can confuse the threading in some mail user agents. In mutt, you can get threading to work using the following…