Introduction To Ruby Programming Language On Linux
December 31st, 2017
Vice President of Technology
This course will teach the basics of the Ruby programming language. We will cover basics of installing Ruby via the package manager of CentOS and Ubuntu, as well as installing Ruby with RVM, the Ruby Version Manager. We will learn the basic syntax of Ruby, and cover how to code our own methods, classes, modules and much more. Through the Intermediate and Advanced sections of the course we will build an Apache log parsing program. We will build upon it throughout the later lessons, until we end up with a nice working log parsing program.
Getting ready to code.
An Introduction to the course materials and the ruby language in general.
This is a brief overview of what this course will cover.
What's a Programming Language?
A Brief introduction about programming languages
Covering the most popular ways to install the ruby environment on both CentOS and Ubuntu, using package managers and RVM.
The Ruby Environment
Covering the basics of what goes into the ruby envrionment
Exercise: Ruby Environment Setup
Learning Basic Ruby Syntax
Take a look at the basic "Hello World" program. Learn a little about methods and method arguments.
Learn what variables are, and how to define them.
Types of Variables
Learn about different types of variables.
Basic Math in Ruby
Learn the basic structure of conditionals in Ruby.
Learn about compound boolean expressions and conditionals
Learn how to use a basic iterator.
Arrays and Hashes
Learn some basic ways of manipulating arrays and hashes. Learn about nested collections.
Learn some basic ways to manipulate strings.
Learn the basic structure of the while loop.
Learn about the for loop.
Learn how to skip around or exit from a loop.
Learn how to write your own methods in Ruby.
Learn about writing methods with arguments.
Learn the basics of classes, and some of the theory behind object oriented programming.
Create your first class, and learn how to instantiate it.
Creating Classes Continued
How to set class inheritance, initializers, and private and protected methods.
Variable Scope Revisited
Variable scope use in class definitions.
Class Methods and Singletons
Learn how to define class methods in Ruby, as well as singleton methods and singleton classes.
Exercise: Getting Acquainted with Ruby (Hello World - Conditionals)
Exercise: Practice with Nested Hashes and Iterators
Exercise: Writing Methods
Exercise: Writing a Program that Utilizes a Class
Start Building a Log Parsing Program
Log Parsing Program
Get started writing an application in ruby. Learn the basics of MVC style programming. Note:We have included files in your home directory, if you are using the provided "Ruby On Linux Ruby 101" server from the dropdown list in your server lab.
Strings and Escapes
Let's do some fancy stuff with ASCII and ANSI escape codes: clear a terminal, move the cursor around, change colors... You might find the following links useful: ASCII Control Codes http://en.wikipedia.org/wiki/ASCII#ASCII_control_code_chart ANSI CSI Codes http://en.wikipedia.org/wiki/ANSI_escape_code#CSI_codes ANSI Color Codes http://en.wikipedia.org/wiki/ANSI_escape_code#Colors
Let's get into the nitty gritty of standard input, and figure out how to interact with our program.
Sometimes the unexpected happens. When it does, ruby raises an exception. This allows the programmer to make contingency plans and keep the program running.
Filling in the MVC stubs
In this lesson we will primarily fill in the code for our MVC. We will focus on code for displaying directory contents, and use the Dir class.
Learn how to manipulate files, open them up, read them, check and set permissions, and write data to them.
Reading a Log File
We'll integrate our knowledge of the File class into our log parsing program. After this course our program will display the contents of a log file.
In order to quickly separate out the data in our log file, we will use a regular expression. But first, we'll learn the basics of regular expressions and how to use them in ruby.
Building the LogEntry Class
In this lesson we will utilize the method we created in the Regular Expressions lesson, and fill out our LogEntry class with data and methods.
Learn about the Time class.
Symbols, Strings, Comments
A general discussion about the differences between strings, symbols. And some details about how to use comments and naming conventions to your advantage.
Modules and Mixins
Learn how to write a module, and use it.
A quick look at the Math module.
Sorting Part 1
In this lesson we will start building the UI for sorting and filtering in our Â log parsing program.
Sorting Part 2
In this lesson we will set up the back end to apply the sorting and filtering categories to our log_entries array.
In this lesson we will apply some exception handling practices to our program, to ensure that it functions properly.
In this lesson we will add a view and controller actions to be able to display a one page printout of a line of the log file.
Method Arguments Addendum
Sometimes you need more than variables when you define methods. Learn about array decomposition, variable numbers of arguments, and keyword arguments.
Dive into concurrent processing models.
Learn about threads in ruby, how to created them and use them in your program.
Learn how to keep data in sync with a thread queue.
We have the tools to build a progress bar on our log parsing program now. Let's put it together.
Sometimes you need to block other threads from processing. You can use a mutex to do that.
Fibers are like threads, but light-weight.
Sub Processes, etc
We'll give an overview of various ways to create sub-processes, lauch external programs, and work with them.