ruby-oop

Explain Ruby OOP concepts with runnable code samples.

187|20|Updated Nov 20, 2025
One-click install
npx skills add https://github.com/TheBushidoCollective/han --skill ruby-oop
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: ruby-oop
Source: https://github.com/TheBushidoCollective/han/tree/main/jutsu/jutsu-ruby/skills/ruby-object-oriented-programming
Command: npx skills add https://github.com/TheBushidoCollective/han --skill ruby-oop

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill covers Ruby's OOP foundations: classes, modules, inheritance, mixins, and method visibility.

Core Features & Use Cases

  • Classes & Modules: Basic structure and mixins.
  • Inheritance & Polymorphism: Reusing behavior with super.
  • Composition: Delegation and composition over inheritance patterns.

Quick Start

Implement a Person class with inheritance and a module mixin.

Frequently Asked Questions about ruby-oop

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I structure classes and inheritance in Ruby?

Ruby classes inherit behavior using the < operator and super keyword. Define a parent class, then create child classes that reuse and override methods. This enables polymorphism—objects respond to the same message differently based on their type.

What's the difference between inheritance and mixins in Ruby?

Inheritance creates a single parent-child hierarchy; mixins use modules to add behavior to multiple unrelated classes. Modules provide composition—mix multiple behaviors into one class without rigid hierarchy constraints.

How do I control method visibility in Ruby classes?

Ruby supports private, protected, and public methods. Public methods are callable from anywhere; private methods only within the class; protected methods accessible by other instances of the same class. Use these keywords to enforce encapsulation.

When should I use composition over inheritance in Ruby?

Composition delegates tasks to other objects rather than inheriting behavior. Use it when relationships are flexible or when a class would inherit conflicting responsibilities. It reduces coupling and makes code easier to test and modify.

Can I use multiple modules in a single Ruby class?

Yes. Include multiple modules in one class to mix in behavior from different sources. Ruby resolves method calls through the method lookup chain—modules included last are searched first, enabling flexible behavior composition.

Do I need to understand metaprogramming to use Ruby OOP patterns?

No. Core OOP patterns—classes, modules, inheritance, and method visibility—work without metaprogramming. Master these fundamentals first; metaprogramming extends OOP for advanced use cases like dynamic method generation.