Very little of this md file was written by me. Whenever I need to dig deep into a method I might write an explanantion here, but for now this serves as a good reference point when I need to figure out how a method works.
For 90% of inquiries -> https://rubyapi.org/
This is very much an in progress md file.
Basic Syntax: https://claude.ai/share/802e0bd5-b2b1-483e-89d5-a5de1c743ad5
Got cc to create a frequency list of each ruby built in function. Here's the breakdown of each.
.map, .join, .to_s, .each, and .dig are the ones you'll see constantly — learn those deeply first.
Array / Enumerable
┌───────────────────┬──────────┬──────────────────────────────────────────┐
│ Method │ Count │ What it does │
├───────────────────┼──────────┼──────────────────────────────────────────┤
│ .map │ 694 │ Transform each element, return new array │
├───────────────────┼──────────┼──────────────────────────────────────────┤
│ .each │ 363 │ Iterate, return original array │
├───────────────────┼──────────┼──────────────────────────────────────────┤
│ .select │ 148 │ Keep elements where block is true │
├───────────────────┼──────────┼──────────────────────────────────────────┤
│ .reject │ 65 │ Drop elements where block is true │
├───────────────────┼──────────┼──────────────────────────────────────────┤
│ .first / .last │ 291 / 53 │ Get first/last element(s) │
├───────────────────┼──────────┼──────────────────────────────────────────┤
│ .compact │ 85 │ Remove nil values │
├───────────────────┼──────────┼──────────────────────────────────────────┤
│ .uniq │ 69 │ Remove duplicates │
├───────────────────┼──────────┼──────────────────────────────────────────┤
│ .sort_by │ 75 │ Sort by a value │
├───────────────────┼──────────┼──────────────────────────────────────────┤
│ .group_by │ 70 │ Group into a hash by key │
├───────────────────┼──────────┼──────────────────────────────────────────┤
│ .flat_map │ 14 │ Map then flatten one level │
├───────────────────┼──────────┼──────────────────────────────────────────┤
│ .filter_map │ 12 │ Map + compact in one pass │
├───────────────────┼──────────┼──────────────────────────────────────────┤
│ .each_with_object │ 12 │ Iterate, accumulate into an object │
├───────────────────┼──────────┼──────────────────────────────────────────┤
│ .flatten │ 9 │ Flatten nested arrays │
├───────────────────┼──────────┼──────────────────────────────────────────┤
│ .reduce / .inject │ 4 │ Fold into single value │
└───────────────────┴──────────┴──────────────────────────────────────────┘
String
┌─────────────┬───────┬────────────────────────────────────┐
│ Method │ Count │ What it does │
├─────────────┼───────┼────────────────────────────────────┤
│ .to_s │ 535 │ Convert to string │
├─────────────┼───────┼────────────────────────────────────┤
│ .join │ 543 │ Array → string with separator │
├─────────────┼───────┼────────────────────────────────────┤
│ .split │ 60 │ String → array on delimiter │
├─────────────┼───────┼────────────────────────────────────┤
│ .strip │ 176 │ Remove leading/trailing whitespace │
├─────────────┼───────┼────────────────────────────────────┤
│ .gsub │ 137 │ Global find/replace │
├─────────────┼───────┼────────────────────────────────────┤
│ .sub │ 46 │ Single find/replace │
├─────────────┼───────┼────────────────────────────────────┤
│ .match │ 60 │ Regex match │
├─────────────┼───────┼────────────────────────────────────┤
│ .downcase │ 130 │ Lowercase │
├─────────────┼───────┼────────────────────────────────────┤
│ .upcase │ 8 │ Uppercase │
├─────────────┼───────┼────────────────────────────────────┤
│ .capitalize │ 12 │ First letter uppercase │
└─────────────┴───────┴────────────────────────────────────┘
Numeric
┌────────────────┬────────┬─────────────────────┐
│ Method │ Count │ What it does │
├────────────────┼────────┼─────────────────────┤
│ .round │ 270 │ Round to N decimals │
├────────────────┼────────┼─────────────────────┤
│ .to_f │ 253 │ Convert to float │
├────────────────┼────────┼─────────────────────┤
│ .to_i │ 134 │ Convert to integer │
├────────────────┼────────┼─────────────────────┤
│ .sum │ 95 │ Sum an array │
├────────────────┼────────┼─────────────────────┤
│ .abs │ 11 │ Absolute value │
├────────────────┼────────┼─────────────────────┤
│ .ceil / .floor │ 12 / 6 │ Round up/down │
├────────────────┼────────┼─────────────────────┤
│ .clamp │ 8 │ Constrain to range │
└────────────────┴────────┴─────────────────────┘
Hash
┌─────────────────┬─────────┬───────────────────────────┐
│ Method │ Count │ What it does │
├─────────────────┼─────────┼───────────────────────────┤
│ .dig │ 162 │ Safe nested key access │
├─────────────────┼─────────┼───────────────────────────┤
│ .merge │ 39 │ Combine two hashes │
├─────────────────┼─────────┼───────────────────────────┤
│ .keys / .values │ 32 / 37 │ Get all keys or values │
├─────────────────┼─────────┼───────────────────────────┤
│ .fetch │ 27 │ Get key, raise if missing │
├─────────────────┼─────────┼───────────────────────────┤
│ .to_h │ 29 │ Convert to hash │
└─────────────────┴─────────┴───────────────────────────┘
General
┌─────────────┬─────────┬────────────────────────────────────┐
│ Method │ Count │ What it does │
├─────────────┼─────────┼────────────────────────────────────┤
│ .count │ 466 │ Count elements (also ActiveRecord) │
├─────────────┼─────────┼────────────────────────────────────┤
│ .size │ 215 │ Length of string/array │
├─────────────┼─────────┼────────────────────────────────────┤
│ .length │ 172 │ Same as size │
├─────────────┼─────────┼────────────────────────────────────┤
│ .min / .max │ 50 / 53 │ Smallest/largest value │
├─────────────┼─────────┼────────────────────────────────────┤
│ .delete │ 37 │ Remove element │
├─────────────┼─────────┼────────────────────────────────────┤
│ .times │ 19 │ Repeat N times │
└─────────────┴─────────┴─────────────────────────────────────┘