Class: ArticleJSON::Import::GoogleDoc::HTML::QuoteParser
- Inherits:
-
Object
- Object
- ArticleJSON::Import::GoogleDoc::HTML::QuoteParser
- Includes:
- Shared::Caption, Shared::Float
- Defined in:
- lib/article_json/import/google_doc/html/quote_parser.rb
Instance Method Summary collapse
-
#content ⇒ Array[ArticleJSON::Elements::Paragraph]
Parse the quote’s nodes to get a set of paragraphs The last node is ignored as it contains the quote caption.
- #element ⇒ ArticleJSON::Elements::Quote
-
#initialize(nodes:, css_analyzer:) ⇒ QuoteParser
constructor
A new instance of QuoteParser.
Methods included from Shared::Float
Methods included from Shared::Caption
Constructor Details
#initialize(nodes:, css_analyzer:) ⇒ QuoteParser
Returns a new instance of QuoteParser.
11 12 13 14 15 16 17 18 19 |
# 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 |
Instance Method Details
#content ⇒ Array[ArticleJSON::Elements::Paragraph]
Parse the quote’s nodes to get a set of paragraphs The last node is ignored as it contains the quote caption
24 25 26 27 28 29 30 31 32 |
# 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 ⇒ ArticleJSON::Elements::Quote
35 36 37 38 39 40 41 |
# File 'lib/article_json/import/google_doc/html/quote_parser.rb', line 35 def element ArticleJSON::Elements::Quote.new( content: content, caption: , float: float ) end |