Class: OembedProxy::GoogleSpreadsheet

Inherits:
Object
  • Object
show all
Defined in:
lib/oembed_proxy/google_spreadsheet.rb

Overview

Google Spreadsheet Fauxembed

Constant Summary collapse

GOOGLE_SPREADSHEET_REGEX =
%r{\Ahttps://docs\.google\.com/spreadsheet.+}.freeze

Instance Method Summary collapse

Instance Method Details

#get_data(url, _other_params = {}) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/oembed_proxy/google_spreadsheet.rb', line 12

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

#handles_url?(url) ⇒ Boolean

Returns:

  • (Boolean)


8
9
10
# File 'lib/oembed_proxy/google_spreadsheet.rb', line 8

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