Code Explainers

Code explainers tagged #module-function

ruby
module Terminal
  module Color
    CODES = {
      black: 30, red: 31, green: 32, yellow: 33,

Building an ANSI color DSL in Ruby

metaprogramming monkey-patching ansi-escapes
Intermediate 9 steps
ruby
module CreditCard
  module_function
 
  def valid?(number)

Validating credit card numbers with Luhn

checksum luhn-algorithm validation
Intermediate 6 steps
ruby
require "bigdecimal"
 
module Money
  CENTS = BigDecimal("0.01")

Handling money safely with BigDecimal in Ruby

bigdecimal rounding currency
Intermediate 7 steps