Class: Repubmark::Elems::Figures

Inherits:
Base
  • Object
show all
Defined in:
lib/repubmark/elems/figures.rb

Instance Attribute Summary

Attributes inherited from Base

#parent

Instance Method Summary collapse

Methods inherited from Base

#absolute_url, #config, #count_words, #html_class, #own_url, parent?, parents, #relative_url, #to_summary_plain, #word_count

Constructor Details

#initialize(parent) ⇒ Figures

Returns a new instance of Figures.



8
9
10
11
# File 'lib/repubmark/elems/figures.rb', line 8

def initialize(parent)
  super parent
  @figures = []
end

Instance Method Details

#figure(name, alt) {|figure| ... } ⇒ Object

Builder methods #

Yields:



39
40
41
42
43
44
# File 'lib/repubmark/elems/figures.rb', line 39

def figure(name, alt)
  figure = Figure.new self, name, alt
  @figures << figure
  yield figure if block_given?
  nil
end

#to_gemtextObject



33
# File 'lib/repubmark/elems/figures.rb', line 33

def to_gemtext = @figures.map(&:to_gemtext).join.freeze

#to_htmlObject

Basic methods #



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/repubmark/elems/figures.rb', line 17

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