Class: Coat::Stitcher
- Inherits:
-
Object
- Object
- Coat::Stitcher
- Defined in:
- lib/coat/stitcher.rb
Overview
Stitches patches into one self-contained HTML document in the PATCHWORK style: every patch bordered with a running stitch, each source keeping its own color, an open seam double-stitched in red thread, and a mended one stitched shut.
Instance Method Summary collapse
-
#initialize(patches, patches_dir, title: "Coat of Many Colors", saying: Sayings.random, mends: {}) ⇒ Stitcher
constructor
A new instance of Stitcher.
- #to_html ⇒ Object
Constructor Details
#initialize(patches, patches_dir, title: "Coat of Many Colors", saying: Sayings.random, mends: {}) ⇒ Stitcher
Returns a new instance of Stitcher.
12 13 14 15 16 17 18 19 20 21 |
# File 'lib/coat/stitcher.rb', line 12 def initialize(patches, patches_dir, title: "Coat of Many Colors", saying: Sayings.random, mends: {}) @patches = patches @patches_dir = patches_dir @title = title @saying = @seams = Seam.find(patches, mends) @open = Seam.crossed(@seams.reject(&:mended?)) @mended = Seam.mended(@seams) end |
Instance Method Details
#to_html ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/coat/stitcher.rb', line 23 def to_html <<~HTML <!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>#{esc(@title)}</title> <style>#{STYLE}</style> </head> <body> <main class="coat"> #{masthead} #{seams_section} #{@patches.map { |patch| article(patch) }.join("\n")} #{colophon} </main> </body> </html> HTML end |