Class: MetaInspector::Parsers::TextsParser

Inherits:
Base
  • Object
show all
Defined in:
lib/meta_inspector/parsers/texts.rb

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from MetaInspector::Parsers::Base

Instance Method Details

#authorObject

Returns the meta author, if present



17
18
19
# File 'lib/meta_inspector/parsers/texts.rb', line 17

def author
  @author ||= meta['author']
end

#best_authorObject

An author getter that returns the first non-nil description from the following candidates:

  • the standard meta description

  • a link with the relational attribute “author”

  • address tag which may contain the author

  • the twitter:creator meta tag for the username



27
28
29
# File 'lib/meta_inspector/parsers/texts.rb', line 27

def best_author
  @best_author ||= find_best_author
end

#best_descriptionObject

A description getter that returns the first non-nill description from the following candidates:

  • the standard meta description

  • the og:description meta tag

  • the twitter:description meta tag

  • the first paragraph with more than 120 characters



42
43
44
# File 'lib/meta_inspector/parsers/texts.rb', line 42

def best_description
  @best_description ||= find_best_description
end

#best_titleObject



12
13
14
# File 'lib/meta_inspector/parsers/texts.rb', line 12

def best_title
  @best_title ||= find_best_title
end

#descriptionObject

Returns the meta description, if present



32
33
34
# File 'lib/meta_inspector/parsers/texts.rb', line 32

def description
  @description ||= meta['description']
end

#titleObject

Returns the parsed document title, from the content of the <title> tag within the <head> section.



8
9
10
# File 'lib/meta_inspector/parsers/texts.rb', line 8

def title
  @title ||= parsed.css('head title').inner_text rescue nil
end