Class: ArticleJSON::Import::GoogleDoc::HTML::Parser
- Inherits:
-
Object
- Object
- ArticleJSON::Import::GoogleDoc::HTML::Parser
- Defined in:
- lib/article_json/import/google_doc/html/parser.rb
Instance Method Summary collapse
-
#initialize(html) ⇒ Parser
constructor
A new instance of Parser.
-
#parsed_content ⇒ Array[ArticleJSON::Elements::Base]
Parse the body of the document and return the result.
Constructor Details
#initialize(html) ⇒ Parser
Returns a new instance of Parser.
7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/article_json/import/google_doc/html/parser.rb', line 7 def initialize(html) doc = Nokogiri::HTML(html) selection = if doc.xpath('//body/div').empty? doc.xpath('//body') else doc.xpath('//body/div') end @body_enumerator = selection.last.children.to_enum css_node = doc.xpath('//head/style').last @css_analyzer = CSSAnalyzer.new(css_node&.inner_text) end |
Instance Method Details
#parsed_content ⇒ Array[ArticleJSON::Elements::Base]
Parse the body of the document and return the result
22 23 24 |
# File 'lib/article_json/import/google_doc/html/parser.rb', line 22 def parsed_content @parsed_content ||= parse_body end |