Ruby
Overview
Ruby is an interpreted, dynamic, object-oriented programming language created by Yukihiro "Matz" Matsumoto in 1995, designed to make programmers productive and happy. Everything in Ruby is an object, and the language emphasizes readable, expressive syntax. Read this when writing Ruby scripts, working with gems, or setting up a Ruby toolchain.
Official sources
Install / setup
On Windows, the official downloads page recommends RubyInstaller; on macOS and Linux/UNIX it recommends third-party version managers (rbenv and RVM) or the distribution package manager. From the official downloads page, using a version manager:
# Linux/UNIX or macOS via rbenv (third-party tool recommended on ruby-lang.org)
rbenv install 4.0.5
rbenv global 4.0.5
Source: https://www.ruby-lang.org/en/downloads/ (current stable listed there is Ruby 4.0.5; substitute the version you need)
Core concepts
- Everything is an object — integers, strings, and even
nil respond to methods; there are no primitives.
- Dynamic typing with duck typing — an object's suitability is determined by the methods it responds to, not its declared class.
- Blocks, procs, and lambdas — first-class chunks of code passed to methods (e.g.
each, map); the foundation of Ruby iteration.
- Mixins via modules — share behavior across classes with
include/extend instead of multiple inheritance.
- Open classes and metaprogramming — classes can be reopened and methods defined at runtime (
define_method, method_missing).
- Gems and Bundler — RubyGems packages libraries; Bundler resolves and locks dependencies via a
Gemfile.
- Exceptions, iterators, closures, and garbage collection are built into the core language.
Best practices
- Follow a community style guide (RuboCop, Shopify, GitLab, or Airbnb guides are linked from ruby-lang.org) and run RuboCop to enforce it.
- Use Bundler with a committed
Gemfile.lock for reproducible dependency installs.
- Prefer iterators and blocks (
each, map, select) over manual index loops for idiomatic, readable code.
- Use a version manager (rbenv/RVM) so each project can pin a known Ruby version.
Common pitfalls
- Treating
nil as falsy-only — in Ruby only nil and false are falsy; 0 and "" are truthy. → Test explicitly when you mean numeric/empty.
- Mutating shared mutable state through reopened classes ("monkey patching") → prefer refinements or composition to limit scope.
- Forgetting that assignment in blocks can leak or shadow variables → keep block-local variables explicit and small.
Examples
# Blocks and iterators
names = ["ada", "grace", "linus"]
names.map { |n| n.capitalize }.each { |n| puts "Hello, #{n}" }
Further reading
Related skills
- ../python — another dynamic, batteries-included scripting language
- ../php — server-side scripting comparison
1---2name: ruby3description: Dynamic, object-oriented language focused on developer happiness; consult for Ruby syntax, idioms, gems, and install/setup.4domain: language5category: language6tags: [ruby, dynamic, object-oriented, scripting, gems]7official_sources:8 - https://www.ruby-lang.org/en/documentation/9 - https://github.com/ruby/ruby10verified: 2026-06-1611metadata:12 source: https://skillmd.com/skills/gabriel7silva/ruby13---1415# Ruby1617## Overview18Ruby is an interpreted, dynamic, object-oriented programming language created by Yukihiro "Matz" Matsumoto in 1995, designed to make programmers productive and happy. Everything in Ruby is an object, and the language emphasizes readable, expressive syntax. Read this when writing Ruby scripts, working with gems, or setting up a Ruby toolchain.1920## Official sources21- Docs: https://www.ruby-lang.org/en/documentation/22- Repo: https://github.com/ruby/ruby23- Install / download: https://www.ruby-lang.org/en/downloads/2425## Install / setup26On Windows, the official downloads page recommends RubyInstaller; on macOS and Linux/UNIX it recommends third-party version managers (rbenv and RVM) or the distribution package manager. From the official downloads page, using a version manager:2728```bash29# Linux/UNIX or macOS via rbenv (third-party tool recommended on ruby-lang.org)30rbenv install 4.0.531rbenv global 4.0.532```3334Source: https://www.ruby-lang.org/en/downloads/ (current stable listed there is Ruby 4.0.5; substitute the version you need)3536## Core concepts37- Everything is an object — integers, strings, and even `nil` respond to methods; there are no primitives.38- Dynamic typing with duck typing — an object's suitability is determined by the methods it responds to, not its declared class.39- Blocks, procs, and lambdas — first-class chunks of code passed to methods (e.g. `each`, `map`); the foundation of Ruby iteration.40- Mixins via modules — share behavior across classes with `include`/`extend` instead of multiple inheritance.41- Open classes and metaprogramming — classes can be reopened and methods defined at runtime (`define_method`, `method_missing`).42- Gems and Bundler — RubyGems packages libraries; Bundler resolves and locks dependencies via a `Gemfile`.43- Exceptions, iterators, closures, and garbage collection are built into the core language.4445## Best practices46- Follow a community style guide (RuboCop, Shopify, GitLab, or Airbnb guides are linked from ruby-lang.org) and run RuboCop to enforce it.47- Use Bundler with a committed `Gemfile.lock` for reproducible dependency installs.48- Prefer iterators and blocks (`each`, `map`, `select`) over manual index loops for idiomatic, readable code.49- Use a version manager (rbenv/RVM) so each project can pin a known Ruby version.5051## Common pitfalls52- Treating `nil` as falsy-only — in Ruby only `nil` and `false` are falsy; `0` and `""` are truthy. → Test explicitly when you mean numeric/empty.53- Mutating shared mutable state through reopened classes ("monkey patching") → prefer refinements or composition to limit scope.54- Forgetting that assignment in blocks can leak or shadow variables → keep block-local variables explicit and small.5556## Examples57```ruby58# Blocks and iterators59names = ["ada", "grace", "linus"]60names.map { |n| n.capitalize }.each { |n| puts "Hello, #{n}" }61```6263## Further reading64- Official documentation hub: https://www.ruby-lang.org/en/documentation/65- API docs for all versions: https://docs.ruby-lang.org/en/6667## Related skills68- ../python — another dynamic, batteries-included scripting language69- ../php — server-side scripting comparison