Ruby Examples
Ruby aligned plain-text table renderer
Renders headers and rows as a neatly aligned plain-text table for terminal output.
Ruby strict Base64 encoder and decoder
Strictly encodes text to Base64 and decodes it back, rejecting malformed input with an error.
Ruby field-level input validator
Validates user fields and returns a hash of field-specific error messages for rendering.
Ruby URL query string encoder and parser
Builds URL query strings from parameters and parses them back into a hash of value arrays.
Ruby JSON parser with clear errors
Parses JSON strings and raises concise, line-aware errors instead of raw parser exceptions.
Ruby bounded thread worker pool
Runs work items on a fixed set of threads and returns ordered results or captured exceptions.
Ruby HTTP JSON fetch with timeouts
Performs a timed HTTP GET, checks the response status, and parses the JSON body.
Ruby validated environment configuration
Reads environment variables with defaults, validates them once, and returns typed settings.
Ruby token bucket rate limiter
Limits average throughput while allowing short bursts using a monotonic-clock token bucket.
Ruby fixed-capacity LRU cache
A small fixed-capacity LRU cache that evicts the least recently used entry on insert.
Ruby multi-key stable record sorter
Sorts records by multiple keys while keeping equal keys stable and placing nils last.
Ruby chunk an enumerable into batches
Splits any enumerable into fixed-size batches, yielding each batch as soon as it is full.
Ruby streaming file line reader
Yields each line and its one-based number from a text file, returning the total line count.
Ruby deep clone and recursive hash merge
Recursively clones hashes and arrays, then merges overrides without mutating either input.
Ruby retry helper with capped jittered backoff
Runs a block and retries failures with capped exponential backoff plus random jitter.