module ArticleJSON::Export::Common::HTML::Exporter

Public Class Methods

new(elements) click to toggle source

@param [Array] elements

# File lib/article_json/export/common/html/exporter.rb, line 7
def initialize(elements)
  @elements = elements
end

Public Instance Methods

html() click to toggle source

Generate a string with the HTML representation of all elements @return [String]

# File lib/article_json/export/common/html/exporter.rb, line 13
def html
  doc = Nokogiri::HTML.fragment('')
  element_exporters.each do |element_exporter|
    doc.add_child(element_exporter.export)
  end
  doc.to_html(save_with: 0)
end

Private Instance Methods

element_exporters() click to toggle source
# File lib/article_json/export/common/html/exporter.rb, line 23
def element_exporters
  @element_exporters ||=
    @elements.map { |e| self.class.namespace::Elements::Base.build(e) }
end