class MetaInspector::Parser

Parses the document with Nokogiri.

Delegates the parsing of the different elements to specialized parsers, passing itself as a reference for coordination purposes

Public Class Methods

new(document, options = {}) click to toggle source
# File lib/meta_inspector/parser.rb, line 11
def initialize(document, options = {})
  @document        = document
  @head_links_parser = MetaInspector::Parsers::HeadLinksParser.new(self)
  @meta_tag_parser = MetaInspector::Parsers::MetaTagsParser.new(self)
  @links_parser    = MetaInspector::Parsers::LinksParser.new(self)
  @download_images = options[:download_images]
  @images_parser   = MetaInspector::Parsers::ImagesParser.new(self, download_images: @download_images)
  @texts_parser    = MetaInspector::Parsers::TextsParser.new(self)

  parsed           # parse early so we can fail early
end

Public Instance Methods

parsed() click to toggle source

Returns the whole parsed document

# File lib/meta_inspector/parser.rb, line 33
def parsed
  @parsed ||= Nokogiri::HTML(@document.to_s)
end