Sha256: eb2e6323dd327daa05d789ed46528fce8c288487a46ad5110344b73a954711a7

Contents?: true

Size: 863 Bytes

Versions: 8

Compression:

Stored size: 863 Bytes

Contents

# frozen_string_literal: true

module OembedProxy
  # Google Spreadsheet Fauxembed
  class GoogleSpreadsheet
    GOOGLE_SPREADSHEET_REGEX = %r{\Ahttps://docs\.google\.com/spreadsheet.+}.freeze

    def handles_url?(url)
      !(url =~ GOOGLE_SPREADSHEET_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 Spreadsheets'
      oembed['provider_url'] = 'https://docs.google.com/spreadsheet/‎'

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

      oembed
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
oembed_proxy-0.3 lib/oembed_proxy/google_spreadsheet.rb
oembed_proxy-0.2.6 lib/oembed_proxy/google_spreadsheet.rb
oembed_proxy-0.2.5 lib/oembed_proxy/google_spreadsheet.rb
oembed_proxy-0.2.4 lib/oembed_proxy/google_spreadsheet.rb
oembed_proxy-0.2.3 lib/oembed_proxy/google_spreadsheet.rb
oembed_proxy-0.2.2 lib/oembed_proxy/google_spreadsheet.rb
oembed_proxy-0.2.1 lib/oembed_proxy/google_spreadsheet.rb
oembed_proxy-0.2.0 lib/oembed_proxy/google_spreadsheet.rb