My First Ruby Gem Part 4: Reap What You Sow

(If you haven’t already, please read Part 1, Part 2, and Part 3)

What I Built

Below is a description of RubyTutor and how to use it. Click Here to read the full documentation on GitHub

RubyTutor was created to be an IRB tool to help beginners become better acquainted with the Ruby language. It has 4 class methods:

explain_full

RubyTutor.explain_full accepts any object as an argument and outputs general information about it, as well as a description of it’s class.

Here’s a sample output:

For newcomers that aren’t familiar with Object-Oriented Programming(OOP), , , and might not make sense to you. I won’t get into the specifics of OOP here, but know that objects are like people. They contain states (length, value) and behaviors (methods). Everything in Ruby is an object, from strings to even . This means they all have states that be accessed and behaviors that can be used.

explain and describe

and separately output the two parts of — just incase you don't want to get the entire spiel.

As of right now, RubyTutor will provide a description for all of the basic classes such as Fixnum, Float, String, etc. I will continue to update description support and improve the descriptions based on any feedback.

Also, to provide credit where it is due, most of the descriptions were copied from the Ruby Docs and edited to be easier to understand for beginners.

available_methods

The last method, , was more of a fix than an original feature. Whenever you call the method on any object, you get a huge jumbled array in return that is hard to read. I wanted it provide a nicer layout and a way of filtering the results.

accepts an object and an optional filter. The filter must be a string and it must match the beginning of the method name.

For example, if you pass in as a filter, it will return all the methods that begin with — not all the methods that have ' in the name. Any filter that isn't a string will get ignored and all the available methods will be outputted.

So that’s RubyTutor in a nutshell. I tried to make a good test suite for it and catch any mistakes or bugs, but if you find something please let me know.

Also, if you want to add to it or make new features to it, go ahead! Fork it, clone it and add to it, my friend.

I hope this inspires others to tackle projects they once thought were out of their reach. And even if you do fail, those are the times we learn the most. So what have you got to lose?

Happy Programming!

References

500K+ Article Views | Software Engineer | Twitter: https://twitter.com/SunnyPaxos | Twitch: https://www.twitch.tv/paxosraft

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store