📖 About Ruby
Ruby is a dynamic, object-oriented language designed for programmer productivity and fun. With its elegant syntax that reads like English, Ruby makes programming enjoyable. Ruby on Rails revolutionized web development with convention over configuration.
🎯 Best For
- Web applications (Ruby on Rails)
- API development
- Scripting and automation
- DevOps tools
- Rapid prototyping
🔧 Key Features
- Everything is an object
- Blocks, procs, and lambdas
- Metaprogramming capabilities
- Duck typing
- Mixins for code reuse
- Expressive and readable syntax
🛠️ Development Tools
Build
bundle install
Test
rspec
Coverage
simplecov
Run
ruby
📄 Package Contents (7 files)
AGENTS_RULES.md
Complete AI agent rules (universal)
- RUBY-specific best practices
- TDD workflow (Red-Green-Refactor)
- DDD principles and patterns
- Git workflow and commit format
- Code quality principles
.cursorrules
Quick reference for Cursor IDE
- Essential rules summary
- Links to full documentation
- Optimized for quick loading
.gitignore
Git exclusions
- RUBY-specific patterns
- Build artifacts
- IDE configuration files
- Dependency directories
AGENTS.md
Quick reference guide
- Common patterns
- Best practices summary
- Quick troubleshooting
README.md
Project template with examples
- Setup instructions
- Sample code and structure
- Testing examples
- Build and run commands
CODE_QUALITY_PRINCIPLES.md
Quality principles and best practices
- Avoid default values (fail-fast)
- Consistency across code paths
- Extract reusable functions
- RUBY-specific examples
CONTRIBUTING.md
Contribution guidelines
- TDD workflow (Red-Green-Refactor)
- Git commit format
- Code review process
- Testing requirements (90% coverage)
💻 Code Examples
Expressive Syntax
class User
attr_reader :id, :name, :email
def initialize(name, email)
@id = SecureRandom.uuid
@name = name
@email = email
end
def valid?
!name.empty? && email.include?('@')
end
end
Blocks and Enumerables
users = [
{ name: 'John', age: 30 },
{ name: 'Jane', age: 25 }
]
adults = users
.select { |user| user[:age] >= 18 }
.map { |user| user.merge(adult: true) }
.sort_by { |user| user[:age] }
Metaprogramming
class User
def self.attr_validated(*attrs)
attrs.each do |attr|
define_method(attr) { instance_variable_get("@#{attr}") }
define_method("#{attr}=") do |value|
raise 'Invalid' if value.nil?
instance_variable_set("@#{attr}", value)
end
end
end
attr_validated :name, :email
end