Ruby Examples

RubyOct 23, 2026

Ruby aligned plain-text table renderer

Renders headers and rows as a neatly aligned plain-text table for terminal output.

formattingtableterminalcli
000
RubyOct 23, 2026

Ruby strict Base64 encoder and decoder

Strictly encodes text to Base64 and decodes it back, rejecting malformed input with an error.

decodingencodingbase64
000
RubyOct 23, 2026

Ruby field-level input validator

Validates user fields and returns a hash of field-specific error messages for rendering.

errorsvalidationforms
000
RubyOct 23, 2026

Ruby URL query string encoder and parser

Builds URL query strings from parameters and parses them back into a hash of value arrays.

query-stringurlencoding
000
RubyOct 23, 2026

Ruby JSON parser with clear errors

Parses JSON strings and raises concise, line-aware errors instead of raw parser exceptions.

parsingerrorsjson
000
RubyOct 23, 2026

Ruby bounded thread worker pool

Runs work items on a fixed set of threads and returns ordered results or captured exceptions.

worker-poolqueuethreads
000
RubyOct 23, 2026

Ruby HTTP JSON fetch with timeouts

Performs a timed HTTP GET, checks the response status, and parses the JSON body.

httpjsontimeout
000
RubyOct 23, 2026

Ruby validated environment configuration

Reads environment variables with defaults, validates them once, and returns typed settings.

environmentconfigvalidation
000
RubyOct 23, 2026

Ruby token bucket rate limiter

Limits average throughput while allowing short bursts using a monotonic-clock token bucket.

throughputtoken-bucketrate-limit
000
RubyOct 23, 2026

Ruby fixed-capacity LRU cache

A small fixed-capacity LRU cache that evicts the least recently used entry on insert.

boundedlrucache
000
RubyOct 23, 2026

Ruby multi-key stable record sorter

Sorts records by multiple keys while keeping equal keys stable and placing nils last.

stablenullssortingcomparator
000
RubyOct 23, 2026

Ruby chunk an enumerable into batches

Splits any enumerable into fixed-size batches, yielding each batch as soon as it is full.

chunkingbatchesenumerable
000
RubyOct 23, 2026

Ruby streaming file line reader

Yields each line and its one-based number from a text file, returning the total line count.

streamlinesfileio
000
RubyOct 23, 2026

Ruby deep clone and recursive hash merge

Recursively clones hashes and arrays, then merges overrides without mutating either input.

clonedeep-mergehash
000
RubyOct 23, 2026

Ruby retry helper with capped jittered backoff

Runs a block and retries failures with capped exponential backoff plus random jitter.

resiliencebackoffretryjitter
000