Class: ArticleJSON::Import::GoogleDoc::HTML::Parser

Inherits:
Object
  • Object
show all
Defined in:
lib/article_json/import/google_doc/html/parser.rb

Instance Method Summary collapse

Constructor Details

#initialize(html) ⇒ Parser

Returns a new instance of Parser.

Parameters:

  • html (String)


7
8
9
10
11
12
13
# File 'lib/article_json/import/google_doc/html/parser.rb', line 7

def initialize(html)
  doc = Nokogiri::HTML(html)
  @body_enumerator = doc.xpath('//body').last.children.to_enum

  css_node = doc.xpath('//head/style').last
  @css_analyzer = CSSAnalyzer.new(css_node&.inner_text)
end

Instance Method Details

#parsed_contentArray[ArticleJSON::Elements::Base]

Parse the body of the document and return the result

Returns:



17
18
19
# File 'lib/article_json/import/google_doc/html/parser.rb', line 17

def parsed_content
  @parsed_content ||= parse_body
end