Class: ArticleJSON::Export::PlainText::Exporter

Inherits:
Object
  • Object
show all
Defined in:
lib/article_json/export/plain_text/exporter.rb

Instance Method Summary collapse

Constructor Details

#initialize(elements) ⇒ Exporter

Returns a new instance of Exporter.

Parameters:



6
7
8
# File 'lib/article_json/export/plain_text/exporter.rb', line 6

def initialize(elements)
  @elements = elements
end

Instance Method Details

#textString

Generate a string with the plain text representation of all elements

Returns:

  • (String)


12
13
14
15
16
17
18
19
# File 'lib/article_json/export/plain_text/exporter.rb', line 12

def text
  @text ||=
    @elements.map do |element|
      ArticleJSON::Export::PlainText::Elements::Base
        .build(element)
        &.export
    end.join.strip
end