It has been about 3 weeks of ON and OFF study in the Ruby Programming language. I haven’t been able to focus properly as it got to a point of it being very confusing and not able to understand what the codes are doing fully, so I took a break from it and been busy with other things.

Now I’m back and giving it even more effort in understanding the coding and purposes of each exercises in the tutorial. I have created some useful tips and notes of what I’ve learnt so far in regards to Ruby coding. Hopefully this could also help other people who is looking to learn Ruby by themselves as well.

TERMINAL/COMMAND PROMPT

cd - Change Directory - move to a specific Folder
dir - Display a list of files and folders
md - Make Directory and creates a new folder
rd - Remove Directory and delete folder(s)
erase - Delete one or more files*

RUBY COMMANDS

To run a ruby file on you type in:
ruby filename.rb
To run ruby on the interactive mode (which allows you to do simple calculations with some direct coding) type in:
irb

To get out of the Interactive Ruby mode simply type:
exit

RUBY CODES


puts - short for put string, it displays the string and ADDS A NEW LINE after executing.
print - it displays the string but does NOT add a new line after executing, but puts does.
" " - putting anything within a double quote "like this" will be a string in Ruby.
""" - with the triple quotes you can print multiple lines, even a whole paragraph.
# - the hash symbol (#) indicates that anything after this is a
comment, the codes won't be functional.
#{variable} - this will call the variable and can be put into a string.
\n - Escape to new line.
\' - Escape to use a single quote (') within a single quoted string.
\" - Escape to use a double quote (") within a double quoted string.
\\ - Escape to use a backslash (\) within a string.
\b - Escape to use a backspace (this will delete one character before the \b).
\t - Horizontal Tab (TAB).
gets - get string input from user, with a NEW LINE adding the \n to the end of the string.
gets.chomp - get string input from user, WITHOUT creating a new line so the \n is not being added.
.to_i - converts strings into integer

MATH SYMBOLS
+ plus
- minus
/ slash
* asterisk
% percent
< less-than > greater-than
<= less-than-equal >= greater-than-equal

VARIABLES & NAMES

Variable = 10 - Variable name = integer value of 10
Variable = AnotherVariable - Variable name = value of another variable, in this case "AnotherVariable"
Variable = "String value" - Variable name = a string value, anything within the double quote (" ")

After reviewing everything I know about Ruby, I came across a very helpful page that sums up the Ruby Codes and other links that can be helpful too.

Codecademy – Ruby Glossary

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.