Class: MetaInspector::Parsers::TextsParser
- Defined in:
- lib/meta_inspector/parsers/texts.rb
Instance Method Summary collapse
-
#author ⇒ Object
Returns the meta author, if present.
-
#best_author ⇒ Object
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.
-
#best_description ⇒ Object
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.
- #best_title ⇒ Object
-
#description ⇒ Object
Returns the meta description, if present.
- #h1 ⇒ Object
- #h2 ⇒ Object
- #h3 ⇒ Object
- #h4 ⇒ Object
- #h5 ⇒ Object
- #h6 ⇒ Object
-
#title ⇒ Object
Returns the parsed document title, from the content of the <title> tag within the <head> section.
Methods inherited from Base
Constructor Details
This class inherits a constructor from MetaInspector::Parsers::Base
Instance Method Details
#author ⇒ Object
Returns the meta author, if present
41 42 43 |
# File 'lib/meta_inspector/parsers/texts.rb', line 41 def ||= ['author'] end |
#best_author ⇒ Object
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 ||= end |
#best_description ⇒ Object
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_title ⇒ Object
12 13 14 |
# File 'lib/meta_inspector/parsers/texts.rb', line 12 def best_title @best_title ||= find_best_title end |
#description ⇒ Object
Returns the meta description, if present
56 57 58 |
# File 'lib/meta_inspector/parsers/texts.rb', line 56 def description @description ||= ['description'] end |
#h1 ⇒ Object
16 17 18 |
# File 'lib/meta_inspector/parsers/texts.rb', line 16 def h1 @h1 ||= find_heading('h1') end |
#h2 ⇒ Object
20 21 22 |
# File 'lib/meta_inspector/parsers/texts.rb', line 20 def h2 @h2 ||= find_heading('h2') end |
#h3 ⇒ Object
24 25 26 |
# File 'lib/meta_inspector/parsers/texts.rb', line 24 def h3 @h3 ||= find_heading('h3') end |
#h4 ⇒ Object
28 29 30 |
# File 'lib/meta_inspector/parsers/texts.rb', line 28 def h4 @h4 ||= find_heading('h4') end |
#h5 ⇒ Object
32 33 34 |
# File 'lib/meta_inspector/parsers/texts.rb', line 32 def h5 @h5 ||= find_heading('h5') end |
#h6 ⇒ Object
36 37 38 |
# File 'lib/meta_inspector/parsers/texts.rb', line 36 def h6 @h6 ||= find_heading('h6') end |
#title ⇒ Object
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 |