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



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

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



51
52
53
# File 'lib/meta_inspector/parsers/texts.rb', line 51

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



66
67
68
# File 'lib/meta_inspector/parsers/texts.rb', line 66

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



56
57
58
# File 'lib/meta_inspector/parsers/texts.rb', line 56

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

#h1Object



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

def h1
  @h1 ||= find_heading('h1')
end

#h2Object



20
21
22
# File 'lib/meta_inspector/parsers/texts.rb', line 20

def h2
  @h2 ||= find_heading('h2')
end

#h3Object



24
25
26
# File 'lib/meta_inspector/parsers/texts.rb', line 24

def h3
  @h3 ||= find_heading('h3')
end

#h4Object



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

def h4
  @h4 ||= find_heading('h4')
end

#h5Object



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

def h5
  @h5 ||= find_heading('h5')
end

#h6Object



36
37
38
# File 'lib/meta_inspector/parsers/texts.rb', line 36

def h6
  @h6 ||= find_heading('h6')
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