Sha256: 84bc108199e3d4bf74f04f06ebc3aae9f8056b577f18969a4232940ebc2ce59c
Contents?: true
Size: 894 Bytes
Versions: 5
Compression:
Stored size: 894 Bytes
Contents
require 'link_thumbnailer/scrapers/base' module LinkThumbnailer module Scrapers module Opengraph class Base < ::LinkThumbnailer::Scrapers::Base def applicable? meta.any? { |node| opengraph_node?(node) } end private def value model.to_s end def model modelize(node, node.attributes['content'].to_s) if node end def node @node ||= meta_xpath(attribute: attribute) || meta_xpath(attribute: attribute, key: :name) end def attribute "og:#{attribute_name}" end def opengraph_node?(node) node.attribute('name').to_s.start_with?('og:') || node.attribute('property').to_s.start_with?('og:') end def meta document.css('meta') end end end end end
Version data entries
5 entries across 5 versions & 1 rubygems