Class: LinkPreview::ExternalDescription
- Inherits:
-
ExternalResource
- Object
- String
- ExternalResource
- LinkPreview::ExternalDescription
- Defined in:
- lib/link_preview/external_description.rb
Instance Attribute Summary collapse
-
#document ⇒ Object
readonly
Returns the value of attribute document.
Instance Method Summary collapse
-
#initialize(document) ⇒ ExternalDescription
constructor
A new instance of ExternalDescription.
- #meta_description ⇒ Object
- #open_graph_description ⇒ Object
- #text ⇒ Object
Methods inherited from ExternalResource
Constructor Details
#initialize(document) ⇒ ExternalDescription
Returns a new instance of ExternalDescription.
5 6 7 8 9 |
# File 'lib/link_preview/external_description.rb', line 5 def initialize(document) @document = document super(text.to_s) end |
Instance Attribute Details
#document ⇒ Object (readonly)
Returns the value of attribute document.
3 4 5 |
# File 'lib/link_preview/external_description.rb', line 3 def document @document end |
Instance Method Details
#meta_description ⇒ Object
19 20 21 |
# File 'lib/link_preview/external_description.rb', line 19 def find_value(document.css("*[name~='description']").first) end |
#open_graph_description ⇒ Object
15 16 17 |
# File 'lib/link_preview/external_description.rb', line 15 def open_graph_description find_value(document.css("*[property~='og:description']").first) end |
#text ⇒ Object
11 12 13 |
# File 'lib/link_preview/external_description.rb', line 11 def text open_graph_description || end |