← Back to Projects

Inn Ruby Gem

A simple Ruby gem that adds the .in? method as an inverse of Ruby's .include? method.

RubyGems Logo

Technologies

  • Ruby
  • RubyGems
  • Object-Oriented Programming
  • Ruby Core Extensions

Features

  • Adds .in? method to objects
  • Inverse of Ruby's .include? method
  • Improves code readability
  • Lightweight with no dependencies

Project Overview

Inn is a lightweight Ruby gem that adds the .in? method to objects, which serves as an inverse of Ruby's built-in .include? method. This simple addition makes code more readable in certain contexts.

I built this gem primarily to go through the process of releasing a gem through the official RubyGems channels. It was a valuable learning experience in understanding the Ruby ecosystem, gem packaging, and distribution.

While the functionality is straightforward, the project represents an important step in my journey as a Ruby developer and contributor to the open-source community.

Usage Example

Using Inn in your Ruby application is straightforward:

require 'inn'

# Example with arrays
musician1 = "john"
musician2 = "pete"
beatles = ["john", "paul", "george", "ringo"]

musician1.in? beatles  # => true
musician2.in? beatles  # => false

# More readable than the alternative
beatles.include? musician1  # => true
beatles.include? musician2  # => false

This simple extension makes code more readable in certain contexts, especially when checking if an element is contained within a collection.

Development Journey

The primary purpose of creating the Inn gem was to learn the process of building and publishing a Ruby gem. The development journey involved:

  • Learning the structure and conventions of Ruby gems
  • Setting up the necessary files (gemspec, Rakefile, etc.)
  • Writing tests to ensure the functionality worked as expected
  • Creating documentation and examples
  • Publishing the gem to RubyGems.org
  • Managing versions and releases

While the functionality of the gem is simple, the experience of going through the entire process of creating and publishing a gem was invaluable. It provided hands-on experience with the Ruby ecosystem's tooling and publishing workflows.