Sha256: 8c094590d8b7c29445332ea264b52889a6aaa60dd7d42fce764f687dea62382b

Contents?: true

Size: 856 Bytes

Versions: 5

Compression:

Stored size: 856 Bytes

Contents

# frozen_string_literal: true

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

    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

5 entries across 5 versions & 1 rubygems

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