Sha256: 485aa5bef43065906af213a66a4cc9598b8931bd18bbb6c95488a8ddad9049a5

Contents?: true

Size: 812 Bytes

Versions: 5

Compression:

Stored size: 812 Bytes

Contents

# frozen_string_literal: true

module OembedProxy
  # Google Docs Fauxembed
  class GoogleDocument
    GOOGLE_DOCUMENT_REGEX = %r{\Ahttps://docs\.google\.com/document.+}

    def handles_url?(url)
      !(url =~ GOOGLE_DOCUMENT_REGEX).nil?
    end

    def get_data(url, _other_params = {})
      return nil unless handles_url? url

      oembed = {}

      oembed['type'] = 'rich'
      oembed['version'] = '1.0'

      oembed['provider_name'] = 'Google Apps Documents'
      oembed['provider_url'] = 'https://docs.google.com/document/‎'

      oembed['html'] = '<iframe class="google-docs document" width="100%" height="500" frameborder="0" scrolling="yes" marginheight="0" marginwidth="0" src="' + url + '"></iframe>'
      oembed['width'] = 500
      oembed['height'] = 500

      oembed
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
oembed_proxy-0.1.4 lib/oembed_proxy/google_document.rb
oembed_proxy-0.1.3 lib/oembed_proxy/google_document.rb
oembed_proxy-0.1.2 lib/oembed_proxy/google_document.rb
oembed_proxy-0.1.1 lib/oembed_proxy/google_document.rb
oembed_proxy-0.1.0 lib/oembed_proxy/google_document.rb