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.
-
#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
18 19 20 |
# File 'lib/meta_inspector/parsers/texts.rb', line 18 def @author ||= ['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
28 29 30 |
# File 'lib/meta_inspector/parsers/texts.rb', line 28 def @best_author ||= 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
43 44 45 |
# File 'lib/meta_inspector/parsers/texts.rb', line 43 def best_description @best_description ||= find_best_description end |
#best_title ⇒ Object
12 13 14 15 |
# File 'lib/meta_inspector/parsers/texts.rb', line 12 def best_title @best_title = ['og:title'] if @main_parser.host =~ /\.youtube\.com$/ @best_title ||= find_best_title end |
#description ⇒ Object
Returns the meta description, if present
33 34 35 |
# File 'lib/meta_inspector/parsers/texts.rb', line 33 def description @description ||= ['description'] 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 |