skillfed

ruby-patterns

Ruby Patterns equips you with creational, structural, and behavioral design patterns alongside modern Ruby idioms and metaprogramming techniques. Reference common shortcuts for conditionals, enumerables, and strings, then dive into factory, builder, decorator, strategy, and observer patterns with working examples. Use it to refactor for clarity and apply proven architectural approaches.

Ruby Patterns provides design patterns, idioms, and metaprogramming techniques to write cleaner, more maintainable Ruby code.

AI-generated summary based on this skill's SKILL.md

8 2 MIT updated by geoffjay

Install

geoffjay/claude-plugins/ruby-patterns · repository language: Python

git clone https://github.com/geoffjay/claude-plugins
cp -r claude-plugins/plugins/ruby-sinatra-advanced/skills/ruby-patterns ~/.claude/skills/ruby-patterns
npx skillfed install geoffjay/claude-plugins/ruby-patterns

Frequently asked questions

AI-generated answers based on this skill's SKILL.md and metadata

What ruby design patterns examples does Ruby Patterns cover?

Ruby Patterns teaches creational, structural, and behavioral design patterns with working examples. You'll learn factory, builder, decorator, strategy, and observer patterns alongside proven architectural approaches for better code organization and reusability.

How can I use ruby metaprogramming to write dynamic methods?

Ruby Patterns covers metaprogramming techniques including method_missing for dynamic method handling and class macros for DSL creation. These approaches let you write flexible, self-modifying code that adapts to runtime conditions while maintaining clarity.

What ruby idioms and best practices improve code clarity?

Ruby Patterns teaches modern idioms including guard clauses for early returns, safe navigation operators for nil-safety, and enumerable shortcuts for concise data transformations. These refactoring techniques make your code more readable and maintainable.

How does Ruby Patterns help with ruby memoization performance?

Ruby Patterns covers memoization and lazy evaluation strategies to optimize performance. You'll learn when and how to cache expensive computations and defer evaluation, improving speed without sacrificing code readability.

What error handling patterns does Ruby Patterns teach?

Ruby Patterns includes custom exceptions handling and result object patterns for robust error management. These approaches provide alternatives to traditional try-catch flows, enabling cleaner control flow and better error propagation.

Can Ruby Patterns help me refactor existing Ruby code?

Yes. Ruby Patterns equips you with idioms, guard clauses, safe navigation operators, and enumerable shortcuts to refactor for clarity. Apply these techniques alongside design patterns to improve architecture and maintainability of existing codebases.

SKILL.md

rendered from the published skill — quoted content, verbatim

Ruby Patterns Skill

Tier 1: Quick Reference - Common Idioms

Conditional Assignment
# Set if nil
value ||= default_value

# Set if falsy (nil or false)
value = value || default_value

# Safe navigation
user&.profile&.avatar&.url
Array and Hash Shortcuts
# Array creation
%w[apple banana orange]  # ["apple", "banana", "orange"]
%i[name email age]        # [:name, :email, :age]

# Hash creation
{ name: 'John', age: 30 }  # Symbol keys
{ 'name' => 'John' }       # String keys

# Hash access with default
hash.fetch(:key, default)
hash[:key] || default
Enumerable Shortcuts
# Transformation
array.map(&:upcase)
array.select(&:active?)
array.reject(&:empty?)

# Aggregation
array.sum
array.max
array.min
numbers.reduce(:+)

# Finding
array.find(&:valid?)
array.any?(&:present?)
array.all?(&:valid?)
String Operations

```ruby

Interpolation

"Hello #{name}!"

Safe interpolation

"Result: %{value}" % { value: result }

Multiline

<<~TEXT Heredoc

(truncated - see the full file via the links below)

Read as markdown · JSON record · Browse the source repository

File tree — 1 file
plugins/ruby-sinatra-advanced/skills/ruby-patterns/SKILL.md

Related skills

Tags

oop-patterns code-refactoring functional-programming metaprogramming-advanced performance-optimization error-handling testing-strategies immutability dsl-design value-objects