Standard Library Tour

\* = default/bundled gems, which can be updated independently.

json, yaml (Psych), csv*, erb Data formats and templating

set, prime*, matrix*, bigdecimal*, rational, complex Data structures and math date, time Dates and times

fileutils, pathname, tmpdir, tempfile, find net/http, uri, open-uri, socket, ipaddr, resolv

openssl, digest, securerandom, base64* Crypto and encoding

logger*, benchmark, pp, objspace, coverage Utilities and diagnostics

optparse, io/console, readline/reline, shellwords, open3, etc CLI and system

forwardable, singleton, delegate, observer*, weakref

monitor, timeout, thread (Queue), fiber Embedded Ruby templates zlib, stringio, strscan Compression, in-memory IO, scanning Readable aliases for $ globals ripper, prism (3.3+) minitest*, test-unit* Testing (bundled gems) rake*, rdoc, irb, debug*

\* = default/bundled gems, which can be updated independently. Several moved from default to bundled gems in Ruby 3.3–3.5, so add them to your Gemfile when using Bundler.

require "securerandom"
SecureRandom.hex(16); SecureRandom.uuid; SecureRandom.alphanumeric(12); SecureRandom.uuid_v7   # (3.3+)
require "digest"
Digest::SHA256.hexdigest("text")
require "erb"
ERB.new("Hello <%= name %>!").result_with_hash(name: "Ana")
require "logger"
log = Logger.new($stdout, level: :info, progname: "app")
log.info("started"); log.error { "lazy evaluated message" }
require "benchmark"
puts Benchmark.measure { 1_000_000.times { "x" * 10 } }
Benchmark.bm { |x| x.report("map") { (1..1e5).map { it * 2 } } }
require "delegate"
class Decorator < SimpleDelegator
  def name = super.upcase
end
require "singleton"
class AppConfig; include Singleton; end
AppConfig.instance
require "strscan"
s = StringScanner.new("3 + 4"); s.scan(/\d+/); s.skip(/\s*/); s.scan(/[+]/)