class ArticleJSON::Import::GoogleDoc::HTML::QuoteParser

Public Class Methods

new(nodes:, css_analyzer:) click to toggle source

@param [Array] nodes @param [ArticleJSON::Import::GoogleDoc::HTML::CSSAnalyzer] css_analyzer

# File lib/article_json/import/google_doc/html/quote_parser.rb, line 11
def initialize(nodes:, css_analyzer:)
  @nodes = nodes.reject { |node| NodeAnalyzer.new(node).empty? }
  @css_analyzer = css_analyzer

  # First node of the quote indicates floating behavior
  @float_node = @nodes.first
  # Last node of the quote contains the caption
  @caption_node = @nodes.last
end

Public Instance Methods

content() click to toggle source

Parse the quote's nodes to get a set of paragraphs The last node is ignored as it contains the quote caption @return [Array]

# File lib/article_json/import/google_doc/html/quote_parser.rb, line 24
def content
  @nodes
    .take(@nodes.size - 1)
    .map do |node|
      ParagraphParser
        .new(node: node, css_analyzer: @css_analyzer)
        .element
    end
end
element() click to toggle source

@return [ArticleJSON::Elements::Quote]

# File lib/article_json/import/google_doc/html/quote_parser.rb, line 35
def element
  ArticleJSON::Elements::Quote.new(
    content: content,
    caption: caption,
    float: float
  )
end