Explain Ruby code

Paste Ruby and Vibe explains the blocks, symbols and mixins that keep it so short.

member.rb

Up to 1,500 characters (about 60 lines). Your code is sent to Unvibe and Anthropic to write the explanation. Don't paste keys or passwords. Common key formats are refused.

Vibe25 lines selected

Press Explain it for the sample, or paste your own code first.

What this Ruby sample shows

mixins
include Greeting adds greet to every Member. include Comparable adds comparison methods such as <, >, == and between?, all built on the <=> method the class defines.
blocks
{ |m| m.points > 20 } is a block passed to select, which keeps the members the block returns true for.
symbols
:name and :points are symbols. map(&:name) turns the symbol into a block that calls name on each member.
metaprogramming
attr_reader :name, :points writes the two reader methods for you when the class is defined, so points works without a def points.

Good to know

  • <=> returns -1, 0 or 1. max and sort only need that method, so the script prints Hi, I'm Ben, then Ana, Ben, then ["Cy", "Ana", "Ben"].
  • greet calls name without self., because a method from a module runs on the object it was mixed into.

Watch out: Comparable also defines == from <=>, so two different members with the same points count as equal: Member.new("Al", 5) == Member.new("Bo", 5) is true.

Explain Ruby code beside your editor

Unvibe is a free app for Mac and Windows. In the app there is no pasting: select code in any app and press Control+U (Ctrl+Alt+U on Windows).

Install on Mac

curl -fsSL https://unvibe.site/install.sh | bash

Paste into Terminal. Unvibe isn't notarized by Apple yet, so this is the smooth path.

No install warning? Use Unvibe in your browser

Opening the .dmg the first time
  1. Open the .dmg and drag Unvibe to Applications.
  2. Open it once; macOS says it can't verify it. Click Done.
    macOS dialog: Unvibe Not Opened, with Done and Move to Trash
    Real screen, macOS 15
  3. System Settings › Privacy & Security › Open Anyway. Confirm, then enter your Mac password. The button shows for about an hour after you try to open Unvibe.
    macOS Privacy & Security, Security section: Unvibe was blocked to protect your Mac, with the Open Anyway button
    Real screen, macOS 15

The Terminal line checks the download against the published SHA-256 and Unvibe's self-signed signature before it installs anything. More help with the first open