class MetaInspector::Parsers::Base

Base class from where the specialized parsers inherit from.

On initialization a main parser is expected, so the specialized parsers can request the parsed document to the main parser, and then perform the searches on it.

The main parser also serves as a message hub between the specialized parsers. For example, the ImagesParser needs to know the base_url in order to absolutify image URLs, so it delegates it to the main parser which, in turn, delegates it to the LinksParser.

Public Class Methods

new(main_parser) click to toggle source
# File lib/meta_inspector/parsers/base.rb, line 16
def initialize(main_parser)
  @main_parser = main_parser
end

Private Instance Methods

cleanup(results) click to toggle source

Cleans up nokogiri search results

# File lib/meta_inspector/parsers/base.rb, line 25
def cleanup(results)
  results.map { |r| r.value.strip }.reject(&:empty?).uniq
end