class ArticleJSON::Import::GoogleDoc::HTML::ListParser
Public Class Methods
new(node:, css_analyzer:)
click to toggle source
@param [Nokogiri::HTML::Node] node @param [ArticleJSON::Import::GoogleDoc::HTML::CSSAnalyzer] css_analyzer
# File lib/article_json/import/google_doc/html/list_parser.rb, line 8 def initialize(node:, css_analyzer:) @node = node @css_analyzer = css_analyzer end
Public Instance Methods
content()
click to toggle source
Parse the list's sub nodes to get a set of paragraphs @return [Array]
# File lib/article_json/import/google_doc/html/list_parser.rb, line 24 def content @node .children .select { |node| node.name == 'li' } .map do |node| ParagraphParser .new(node: node, css_analyzer: @css_analyzer) .element end end
element()
click to toggle source
@return [ArticleJSON::Elements::List]
# File lib/article_json/import/google_doc/html/list_parser.rb, line 36 def element ArticleJSON::Elements::List.new( list_type: list_type, content: content ) end
list_type()
click to toggle source
Determine the list type, either ordered or unordered @return [Symbol]
# File lib/article_json/import/google_doc/html/list_parser.rb, line 15 def list_type case @node.name when 'ol' then :ordered when 'ul' then :unordered end end