txus/explain
Explain explains your Ruby code in natural language.
{ "createdAt": "2012-10-07T15:57:15Z", "defaultBranch": "master", "description": "Explain explains your Ruby code in natural language.", "fullName": "txus/explain", "homepage": null, "language": "Ruby", "name": "explain", "pushedAt": "2012-10-07T16:10:25Z", "stargazersCount": 108, "topics": [], "updatedAt": "2025-11-07T14:56:48Z", "url": "https://github.com/txus/explain"}explain
Section titled “explain”Explain explains your Ruby code in natural language. It is intended to be a tool for beginners who aren’t yet very familiar with programming.
It is a work in progress (a bit rough on the edges), so don’t be mad. It will get better over time ;)
(Explain runs only on Rubinius.)
Installation
Section titled “Installation”Install Rubinius if you don’t have it yet:
$ rvm install rbx-head$ rvm use rbx-headInstall explain as a gem:
$ gem install explainGiven some example Ruby code, for example this in examples/person.rb:
class Person def walk(distance) @distance += distance @hunger += 2 end
def eat(food) @hunger -= food.nutritional_value endendWe execute explain from the command line:
$ explain examples/person.rbAnd it will output:
Let's describe the general attributes and behavior of any Person.
A Person can **walk**, given a specific distance. This is described asfollows: its distance will be its distance plus what we previously defined as`distance`. Finally we return its hunger will be its hunger plus the number2..
A Person can **eat**, given a specific food. This is described as follows:Finally we return its hunger will be its hunger minus the result of calling**nutritional_value** on what we previously defined as `food`..And with this we're done describing a Person.Contributing
Section titled “Contributing”- Fork it
- Create your feature branch (
git checkout -b my-new-feature) - Commit your changes (
git commit -am 'Add some feature') - Push to the branch (
git push origin my-new-feature) - Create new Pull Request
Who’s this
Section titled “Who’s this”This was made by Josep M. Bach (Txus) under the MIT license. I’m @txustice on twitter (where you should probably follow me!).