Static Analysis in Ruby

Let’s say that you want to parse your source code to find all your methods, where they are defined & what arguments do they take. How can you do this? Your first idea might be to write a regexp for it… But is there a better way? Yes! Static analysis is a technique you can … Read more

How to Debug & Fix Your Ruby Programs

How often does your program do exactly what you want the first time around? Many times our programs dont’t work like we expect, so we have to use the art of debugging ruby to help us finding out why. You may be familiar with the following error message: undefined method ‘some_method’ for nil:NilClass This means … Read more

How to Use Ruby Threads: An Easy To Understand Tutorial

What is a thread in Ruby? Threads make your Ruby programs do multiple things at the same time. Things like: Reading multiple files Handling multiple web request Making multiple API connections As a result of using threads, you’ll have a multi-threaded Ruby program, which is able to get things done faster. But one warning… In … Read more

Mastering Ruby Regular Expressions

Ruby regular expressions (ruby regex for short) help you find specific patterns inside strings, with the intent of extracting data for further processing. Two common use cases for regular expressions include validation & parsing. For example: Think about an email address, with a ruby regex you can define what a valid email address looks like. … Read more

How To Read & Write Files in Ruby (With Examples)

Today you’ll learn how to read & write files in Ruby so you can extract the contents, create new files, and find the information you need! Let’s do this! How to Read Files In Ruby You can read a file in Ruby like this: Open the file, with the open method. Read the file, the … Read more