48 lines
974 B
Ruby
48 lines
974 B
Ruby
# frozen_string_literal: true
|
|
|
|
module Repubmark
|
|
module Elems
|
|
class Figures < Base
|
|
parents :Canvas
|
|
|
|
def initialize(parent)
|
|
super parent
|
|
@figures = []
|
|
end
|
|
|
|
#################
|
|
# Basic methods #
|
|
#################
|
|
|
|
def to_html
|
|
raise 'Expected two figures' unless @figures.size == 2
|
|
|
|
[
|
|
"<div#{html_class(:figures_wrap)}>\n",
|
|
*@figures.flat_map do |figure|
|
|
[
|
|
"<div#{html_class(:figures_left)}>\n",
|
|
figure.to_html,
|
|
"</div>\n",
|
|
]
|
|
end,
|
|
"</div>\n",
|
|
].join.freeze
|
|
end
|
|
|
|
def to_gemtext = @figures.map(&:to_gemtext).join.freeze
|
|
|
|
###################
|
|
# Builder methods #
|
|
###################
|
|
|
|
def figure(name, alt)
|
|
figure = Figure.new self, name, alt
|
|
@figures << figure
|
|
yield figure if block_given?
|
|
nil
|
|
end
|
|
end
|
|
end
|
|
end
|