ryanwold.net

A civic-minded citizen seeking the singularity

Back to Entries

Ruby Notes

release
Date: 2010-03-14
Tags: ruby notes

Ruby Require vs. Include Include vs Require

You must first Require a file/codebase. Requires takes a string as an argument. For example:

require "code"
load "code.rb"

You must then "include" a module or class. Instead of a string, inlude takes a constant for an argument. For example:

include ClassName

I was looking into the differences between Classes and Modules. A Class can be made into a new instance of an object, but a Module cannot. A Module can contain the same things as a Class, but is used typically to extend of modify the behavior the Class that includes a "Module". Including a Module is often referred to a "mix-in".

I found this link about mixins particularly helpful.

Now, I can consolidate my custom code into Classes and Modules more appropriately.

By Ryan Wold · © 2010–2026 Ryan Wold

Licensed CC BY-NC 4.0. AI training requires a license — machine-readable terms.

Enjoyed this? — any BSV wallet, HandCash, or plain old dollars.

Leave a tip

Tips go directly to a Bitcoin SV address I control — peer to peer, no platform in between. A few thousand satoshis is a fraction of a cent; it's the gesture that counts.

From any BSV wallet

Scan the QR code with your wallet's camera, or copy the address.

177DwUfSTW8RkFBJzYYcgr1YB8ngbhTYAc

With HandCash or any paymail wallet

Paymail is an email-style address for Bitcoin wallets. Send any amount to afomi@handcash.io

First time using Bitcoin? Yours Wallet is an open-source browser extension wallet, and HandCash is an easy mobile wallet — either takes a minute to set up.

Prefer regular money? Support via OpenCollective.