Ruby Ranges: How Do They Work?

What is a Range in Ruby & how does it work? A range is an object which has a starting value & ending value, they help you create sequences that span the whole range between these two values. You could go from 1 to 20, or from “a” to “z”. In this article you’ll discover: … 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 the language itself. These classes offer a variety of utilities like: Base64 encoding Prime number generation DNS resolution In this article I’m going to show you 5 of these classes with useful examples. Ruby Logger … 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 the numbers is picked. But if you want some numbers to be picked more often than others you will need a different strategy: a weighted random number generator. Some practical applications include: the loot table … Read more

Ruby Metaprogramming: Real-World Examples

You may have read about Ruby metaprogramming before. But… It can be a bit confusing if you don’t have a few specific examples. That’s why in this article: We’re going to look at some popular open-source projects using Ruby metaprogramming. Projects like: Rails Sinatra Paperclip gem All of them use some form of metaprogramming. Let’s … 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! In this post I will teach you, step-by-step, how to create a program that can interact with the Twitter API and do things like looking for certain keywords or send automated replies. Let’s get started! … Read more