Code Explainers

Code explainers tagged #module-functions

ruby
module AppConfig
  module_function
 
  def fetch(key, default: nil, required: false)

Typed environment variable config in Ruby

environment-variables type-coercion configuration
Intermediate 7 steps
ruby
module DurationFormatter
  UNITS = [
    ['week', 604_800],
    ['day', 86_400],

Turning seconds into human-readable durations in Ruby

greedy-decomposition modular-arithmetic formatting
Intermediate 7 steps