Class: Snippet::Facebook
- Inherits:
-
Object
- Object
- Snippet::Facebook
- Defined in:
- lib/snippet/facebook.rb
Overview
gets facebook-formatted snippets
Class Method Summary collapse
Class Method Details
.get_meta(doc) ⇒ Object
4 5 6 7 8 9 10 11 12 13 |
# File 'lib/snippet/facebook.rb', line 4 def (doc) img = doc.root.xpath("//meta[@property='og:image']/@content").first img = img.value unless img.nil? text = doc.root.xpath("//meta[@property='og:description']/@content").first text = text.value.to_s unless text.nil? title = doc.root.xpath("//meta[@property='og:title']/@content").first title = title.value unless title.nil? return nil if title.nil? { title: title, text: text, img: img } end |