Ruby Gems.. They are your friends, your helpers: ruby2d

If you’re here reading this, you’re either a part of my intelligent, lovely cohort or you’ve come to learn more about ruby gems, specifically ruby2d. You want to know why this specific gem stands out and what it can do.

You're here, why not learn something new :D

Now if somehow you’ve stumbled upon this blog post at random, i encourage you to stay and learn.Your first thoughts might be , what’s a ruby gem? I can tell you i am definitely not referring to the precious stone, they are precious though.

Ruby Gems ??

Put simply ruby gems are open source libraries, containing ruby code and packaged with extra data. Ruby Gems allow programmers to use code within the gems, making our work easier and faster. They are truly magical and there are so many that you could easily get lost down a rabbit hole in them. Gems can be used for all sorts of purposes and installing them is far easier than you could imagine.

On a quick search it says there are over 133,000+ ruby total gems available , with over 14billion+ having been downloaded. So to give you a better understanding i’ll point out some popular and common ruby gems you may already be using.

Pry : an interactive shell for the Ruby programming language. It is notable for its Smalltalk-inspired ability to start a REPL within a running program. This lets programmers debug and modify the current state of a system.

RSpec :a testing tool for Ruby, created for behavior-driven development (BDD). It is the most frequently used testing library for Ruby in production applications

JSON : provides an API for parsing JSON from text as well as generating JSON text from arbitrary Ruby objects. It’s easily the most used JSON library in Ruby.

Active Record:to put it inelegantly, the gem that takes care of all the database stuff. It’s known as an “ORM”. takes data which is stored in a database table using rows and columns, which needs to be modified or retrieved by writing SQL statements , and it lets you interact with that data as though it was a normal Ruby object.

Rubo Cop: a Ruby static code analyzer (a.k.a. linter) and code formatter. Out of the box it will enforce many of the guidelines outlined in the community Ruby Style Guide. Apart from reporting the problems discovered in your code, RuboCop can also automatically fix many of them for you.

Installing gems !

Installing gems can be done through a simple command:
gem install <Gem-name >. If there is a specific version, you would simply type it out the way it is shown. Through the command Gem-list you can get a list of all locally installed gems !

Here is an example of installing rails ! Rails is a gem and It provides the fullstack framework that allows ruby to transform into web applications.

And just like that you could have installed your brand new ruby gem. This is considering the rest of your environment is set up, for more on that you can check this link. You must also include it in your gems and require it on top.

Depending on the gem you would have to require it in the same format. The show was necessary for ruby2d
Ruby2D logo


Now we can talk about ruby2d ! Ruby2d makes cross platform 2d applications in ruby !It is an entirely open-source project (including its dependencies) built by dedicated folks who believe creating 2D applications should be simple, natural, and joyful, in the spirit of the Ruby language itself.

I know we are in 2020, so why would a 2d application be so fun ? In simple things people tend to find joy. Within the 2d applications in ruby 2d , you can build shapes, images, and sprites. You can add text, audio or inputs to your application.

MIND BLOWING ?? I know ..

They have a small code snipet within the first page to grab your attention but that just takes you to a basic triangle.. but once you've become comfortable you can do far more, they challenge you to play with the colors, to try different shapes and to try the text. They provide simple yet understandable guidance and have many other examples on site. The gem is simple yet very versatile

The code for the basic triangle.

By following the simple and straight forward code snipet above and or copy and pasting it and running you'll get an image. It explains the rest of the possible actions in a similar matter. Like all gems it can take time to become comfortable and familiar with one. But practice can make you better, errors are a programers motivation and our friends the gems are here to help us work smarter instead of harder.

mY tRiAnGle. I wanted to show yo a bit more than the triangle alone. I included the shapes circle and square, text and two sprites

Ruby 2D is in my opinion a gem hidden among gems. Below is an example of the most mind boggling ruby2d game i have come across myself. Flappy bird was THE game back in 2014. To see someone having recreated the game using ruby 2d left me in shock and led to my rabbit hole dive into the gem. This game was a 2d cross platform application that caught the attention of millions and led to it being removed from the app store out of guilt to addiction to the game. Congrats on your introduction to ruby2d , now that you know more about gems , specifically ruby2d who knows you might be the next flappy bird creator.

Flappy Bird 2013–2014

Full Stack Software Engineer || Entrepreneur at heart , engineer by training. Comedian in the eyes off my peers.