Sha256: d1c86ee88003a68663adc86284d6005cc0168a14a98167a328f491aabad50a4d

Contents?: true

Size: 580 Bytes

Versions: 62

Compression:

Stored size: 580 Bytes

Contents

module Onebox
  module Engine
    class XkcdOnebox
      include Engine
      include LayoutSupport
      include JSON

      matches_regexp(/^https?:\/\/(www\.)?(m\.)?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
          {
            link: @url,
            title: raw['safe_title'],
            image: raw['img'],
            description: raw['alt']
          }
        end
    end
  end
end

Version data entries

62 entries across 62 versions & 1 rubygems

Version Path
onebox-1.8.26 lib/onebox/engine/xkcd_onebox.rb
onebox-1.8.25 lib/onebox/engine/xkcd_onebox.rb
onebox-1.8.24 lib/onebox/engine/xkcd_onebox.rb
onebox-1.8.23 lib/onebox/engine/xkcd_onebox.rb
onebox-1.8.22 lib/onebox/engine/xkcd_onebox.rb
onebox-1.8.21 lib/onebox/engine/xkcd_onebox.rb
onebox-1.8.20 lib/onebox/engine/xkcd_onebox.rb
onebox-1.8.19 lib/onebox/engine/xkcd_onebox.rb
onebox-1.8.18 lib/onebox/engine/xkcd_onebox.rb
onebox-1.8.17 lib/onebox/engine/xkcd_onebox.rb
onebox-1.8.16 lib/onebox/engine/xkcd_onebox.rb
onebox-1.8.15 lib/onebox/engine/xkcd_onebox.rb
onebox-1.8.14 lib/onebox/engine/xkcd_onebox.rb
onebox-1.8.13 lib/onebox/engine/xkcd_onebox.rb
onebox-1.8.12 lib/onebox/engine/xkcd_onebox.rb
onebox-1.8.11 lib/onebox/engine/xkcd_onebox.rb
onebox-1.8.10 lib/onebox/engine/xkcd_onebox.rb
onebox-1.8.9 lib/onebox/engine/xkcd_onebox.rb
onebox-1.8.8 lib/onebox/engine/xkcd_onebox.rb
onebox-1.8.7 lib/onebox/engine/xkcd_onebox.rb