Class: MetaInspector::Parser
- Inherits:
-
Object
- Object
- MetaInspector::Parser
- Extended by:
- Forwardable
- Defined in:
- lib/meta_inspector/parser.rb
Overview
Parses the document with Nokogiri.
Delegates the parsing of the different elements to specialized parsers, passing itself as a reference for coordination purposes
Instance Method Summary collapse
-
#initialize(document, options = {}) ⇒ Parser
constructor
A new instance of Parser.
-
#parsed ⇒ Object
Returns the whole parsed document.
Constructor Details
#initialize(document, options = {}) ⇒ Parser
Returns a new instance of Parser.
11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/meta_inspector/parser.rb', line 11 def initialize(document, = {}) @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 = [: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 |
Instance Method Details
#parsed ⇒ Object
Returns the whole parsed document
33 34 35 |
# File 'lib/meta_inspector/parser.rb', line 33 def parsed @parsed ||= Nokogiri::HTML(@document.to_s) end |