✨ ARCANUM RUNE DIFFICULTY: Adept Behavioral

The Tactical Interchange (Strategy)

Defining a family of algorithms and making them interchangeable through pattern branches.

✧ GANG OF FOUR LINEAGE & ARCANUM ✧
GOF DESIGN PATTERN: Strategy
ARCANUM SCHOOL: Transmutation // Streamweaving
SCRIBE / ARCHON: Joshua Edward McLaughlin Cox
CANONICAL REGISTRATION:
// CODEX INCANTATION //
# Strategy: Choose formatting strategy based on header line
1 {
  /STRATEGY:JSON/ b json_strategy
  /STRATEGY:XML/ b xml_strategy
}

:json_strategy
# Convert lines to JSON
s/\(.*\)/{"data": "\1"}/
b end

:xml_strategy
# Convert lines to XML
s/\(.*\)/<data>\1<\/data>/
b end

:end
Runic Tags: #sed #behavioral #strategy