Sha256: 458e1abd9b6f4fae5ae7d33bcf82815c448ae8293a210f9db09d36b3ce446ad9
Contents?: true
Size: 550 Bytes
Versions: 6
Compression:
Stored size: 550 Bytes
Contents
module Onebox module Engine class XkcdOnebox include Engine include LayoutSupport include JSON matches_regexp(/^https?:\/\/(www\.)?xkcd\.com\/\d+/) def url "https://xkcd.com/#{match[:comic_id]}/info.0.json" end private def match @match ||= @url.match(%{xkcd\.com/(?<comic_id>\\d+)}) end def data { url: @url, name: raw['safe_title'], image: raw['img'], description: raw['alt'] } end end end end
Version data entries
6 entries across 6 versions & 1 rubygems