class ArticleJSON::Import::GoogleDoc::HTML::HeadingParser
Public Class Methods
new(node:)
click to toggle source
@param [Nokogiri::HTML::Node] node
# File lib/article_json/import/google_doc/html/heading_parser.rb, line 7 def initialize(node:) @node = node end
Public Instance Methods
content()
click to toggle source
The raw text content of the heading, without any markup @return [String]
# File lib/article_json/import/google_doc/html/heading_parser.rb, line 13 def content @node.inner_text end
element()
click to toggle source
@return [ArticleJSON::Elements::Heading]
# File lib/article_json/import/google_doc/html/heading_parser.rb, line 31 def element ArticleJSON::Elements::Heading.new(level: level, content: content) end
level()
click to toggle source
Determine the level of the heading The level corresponds to the header tag, e.g. `<h3>` is level 3. @return [Integer]
# File lib/article_json/import/google_doc/html/heading_parser.rb, line 20 def level case @node.name when 'h1' then 1 when 'h2' then 2 when 'h3' then 3 when 'h4' then 4 when 'h5' then 5 end end