class Snippet::Any
gets not-facebook formatted snippet
Public Class Methods
get_meta(doc)
click to toggle source
# File lib/snippet/any.rb, line 4 def get_meta(doc) title = doc.root.xpath("//meta[@name='title']/@content").first || \ doc.root.xpath("//title").to_s title = title.value unless title.respond_to? :capitalize title.gsub!(/<[^>]+>/m,'').strip! text = doc.root.xpath("//p/text()").first || doc.root.xpath("//meta[@name='description']/@content").first img = doc.root.xpath("//link[@rel='image_src']/@href").first img = img.value unless img.nil? { title: title, text: text.to_s, img: img } end