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



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

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



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

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



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

def best_description
  @best_description ||= find_best_description
end

#best_titleObject



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

def best_title
  @best_title = meta['og:title'] if @main_parser.host =~ /\.youtube\.com$/
  @best_title ||= find_best_title
end

#descriptionObject

Returns the meta description, if present



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

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