Ruby Post Index

Ruby Is Hiding Errors From You!

Ruby will intentionally hide some exceptions from you. Sometimes this can be useful. Like when using the Kernel#loop method with ...
Read More

Learn to Implement & Use Prefix Trees in Ruby

A prefix tree (also known as a trie) is a data structure that helps you organize a word list & ...
Read More

Atom Tricks, Plugins & Shortcuts for Ruby Developers

If you are using Atom for Ruby development then you probably know that there are plugins (packages in Atom) that ...
Read More

Build Your Own Link Shortener App with Ruby & Sinatra

If you are looking for a little project to work on & practice your Ruby skills then you are in ...
Read More

Performance Improvements in Ruby 2.5

New Ruby versions keep improving & Ruby 2.5 is no different. Ruby 2.5 is introducing some optimizations: String interpolation will ...
Read More

Turn Rows Into Columns With The Transpose Method

Imagine that you have a perfect grid, let's say a 3x3 square, in the form of a multi-dimensional array. And ...
Read More

Array#zip Method

Let's say that you want to compare two arrays, element by element so you can find the differences. Or maybe ...
Read More

7 Little-Known Ruby Methods To Help You Write Better Code

Did you know that using the right Ruby method can save you a lot of work? The more methods you ...
Read More

Build an Image Downloader in Ruby

Build an Image Downloader in Ruby Watch this video to learn how to build an image dowloader program step-by-step using ...
Read More

Code Reading Adventures in The Land of Ruby

I always recommend code reading, not only because it's good for improving your skills, but also because it's like an ...
Read More

A Quick Analysis of How Sinatra Works

What happens when you require sinatra into your project? How does route matching work? How are requests & responses processed? ...
Read More

Practical Linked List in Ruby

This is the 3rd entry in the "Practical Computer Science in Ruby" series! Today we are going to talk about ...
Read More

The Ultimate Guide to Ruby Sorting

How many ways are there to sort an array in Ruby? More than you think... ...even though Array only has ...
Read More

Everything You Need to Know About Ruby Constants

There is a lot more to Ruby constants that you might think... For example, you can change the value of ...
Read More

The Hidden Costs of Metaprogramming

Metaprogramming sounds like a very fancy word, but is it any good? It can be useful, but many people don't ...
Read More

There Is No Magic in Ruby

You may have heard (or even said yourself) that Rails / Ruby has too much magic... ...but where does that ...
Read More

Practical Graph Theory in Ruby

This is the next installment in the "Practical Computer Science" series, where you will learn how to apply classic computer ...
Read More

An Object That Behaves Like a File?

If you are looking for an object that behaves like an IO object (files, sockets, etc), but that you can ...
Read More

Stop Using Case Statements in Ruby

Are you using the full power of OOP (Object-Oriented Programming) or are you missing out? If you are taking decisions ...
Read More

Ruby Under The Hood: Memory Layout of an Object

If you enjoy seeing how things work under the hood I think you are going to love this post... ...because ...
Read More

Practical Computer Science in Ruby: Using Stacks to Solve Problems

If you don't have a CS (Computer Science) degree you might feel like you are missing out on something... Or ...
Read More

How to Make Your Classes More Powerful by Implementing Equality

How do you compare two things in Ruby? Using == as you already know... but did you know that == ...
Read More

15 Weird Things About Ruby That You Should Know

15 Weird Things About Ruby That You Should KnowBy Jesus CastelloRuby is an amazing language with a lot of interesting ...
Read More

Hash Tables Explained

One of my favorite data structures is the hash table because it's simple & powerful. You probably have used it ...
Read More

Packing & Unpacking: A Guide to Reading Binary Data in Ruby

Working with text is a lot easier than working with binary data... ...with text you can use regular expressions & ...
Read More

How To Spy on Your Ruby Methods

Ruby has a built-in tracing system which you can access using the TracePoint class. Some of the things you can ...
Read More

9 New Features in Ruby 2.4

It has become a tradition to release new Ruby versions on Christmas. And in this post I want to cover ...
Read More

How to Write a Port Scanner in Ruby

Why would you want to write a port scanner? Writing a port scanner is a great way to learn the ...
Read More

Behind The Scenes: How Numbers Work in Ruby

Ruby 2.4 will be merging both Fixnum & Bignum into the same class (Integer) so I think this is a ...
Read More

Writing a Shell in 25 Lines of Ruby Code

If you use Linux or Mac, every time you open a terminal you are using a shell application. A shell ...
Read More

Building Your Own Linux Tools with Ruby: A Practical Guide

Tools like ps, top & netstat are great, they give you a lot of information about what's going with your ...
Read More

Ruby Ranges: How Do They Work?

Have you ever wondered how ranges work in Ruby? Even if you haven't, isn't it fun to discover how things ...
Read More

5 Useful Examples From The Ruby Standard Library

The Ruby Standard Library is a series of modules & classes that come with Ruby but are not part of ...
Read More

How to Generate Weighted Random Numbers

Random numbers usually follow what we call a 'uniform distribution', meaning that there is the same chance that any of ...
Read More

Metaprogramming in The Wild

You may have read about Ruby metaprogramming before & maybe you have used it in some of your projects, but ...
Read More

Learn to Use the Twitter API with Ruby

Do you want to learn how to write a Twitter application using Ruby? Then you are in the right place! ...
Read More

My New Favorite Enumerable Method

Enumerable is an amazing module, and it's a big part of what makes Ruby such a great programming language. Enumerable ...
Read More

Exploring MRI Source Code

If you have been using Ruby for a while you are probably curious about how some things work under the ...
Read More

The Ultimate Guide to Blocks, Procs & Lambdas

In this post you will learn everything you need to know about Ruby procs, blocks & lambdas. Understanding Blocks Blocks ...
Read More

11 Ruby Tricks You Haven’t Seen Before

1. Deep copy When you copy an object that contains other objects, like an Array, only a reference to these ...
Read More

Understanding Mutable Objects & Frozen Strings

Let's talk about mutability. What does it mean for an object to be mutable? Don't let the fancy word deceive ...
Read More

Ruby Time & Date Classes

If you want to do anything related with time you probably want to use some sort of class that can ...
Read More

Introduction to Refactoring

If you aren't familiar with the term, refactoring is the act of improving the quality of code without changing what ...
Read More

The Many Uses Of Ruby Case Statements

Whenever you need to use some if / elsif statements you could consider using a Ruby case statement instead. In ...
Read More

Working with APIs

APIs are great because they let you interact with other applications, but they can be a bit intimidating if you ...
Read More

N-gram Analysis for Fun and Profit

What would you do if you are given a big collection of text and you want to extract some meaning ...
Read More

Recursion and Memoization in Ruby

Have you ever wondered if there is an alternative to iteration? Well I have good news for you: there is, ...
Read More

Static Analysis in Ruby

If you want to know something about your source code, like the name and line number of all your methods, ...
Read More

Debugging Your Ruby Programs

How often does your program do exactly what you want the first time around? Many times our programs won't work ...
Read More

Using Ruby Threads

Using ruby threads you can make your applications do multiple things at the same time, making them faster. In MRI ...
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 that ...
Read More

Using Struct and OpenStruct

Sometimes you just want an object that can store some data for you, the struct class is very useful in ...
Read More

Working with files and folders

Data processing is a common task in programming. Data can come from many places: files, network, database, etc. In this ...
Read More

Mastering Ruby Arrays

Ruby arrays are a fundamental data structure that is used to store data in memory. Inside a Ruby array you ...
Read More

Ruby Network Programming

Do you want to create custom network clients & servers in Ruby? Or just understand how that works? Then you ...
Read More

How to build a parser with Ruby

Parsing is the art of making sense of a bunch of strings and converting them into something we can understand ...
Read More

How to write your own Caesar cipher encoder

Let's do a little exercise together! Have you ever heard of the Caesar cipher? Julius Caesar used this technique to ...
Read More

Random Numbers and Strings in Ruby

Randomness can make things more interesting in games or it can help make your sites more secure. In Ruby, there ...
Read More

Rubocop – Your personal code reviewer

Rubocop is a static analysis tool that will help you keep your code void of a number of style and ...
Read More

Ruby tracing – A useful debugging tool

Tracing is following all the steps taken by a program, specially function calls/methods, this can be a useful debugging tool ...
Read More

Alphanumeric sorting

Time for a bit more sorting. Today our task is to sort an array of file names based on the ...
Read More

Ruby: fine grained sorting

Ruby sorting is really easy, lets see some examples. If we had this array: ["abc", "aaa", "add", "bcc", "baa"] sorting ...
Read More

Ruby vs Java – Strings

Let's see how we can do some basic operations with strings with 2 languages, starting with how we declare a ...
Read More

Parsing HTML in Ruby

If you have ever tried to write a scrapping tool you probably had to deal with parsing HTML. This task ...
Read More

Ruby String Formatting

Let's talk about how you can format strings in ruby. Why would you want to format a string? Well, you ...
Read More