Class: OembedProxy::AssociatedPress

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

Overview

Associated Press Interactives Fauxembed

Constant Summary collapse

AP_REGEX =
%r{\Ahttps?:\/\/(?:hosted\.ap\.org\/interactives|interactives\.ap\.org)\/.+}.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/associated_press.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'] = 'Associated Press'
  oembed['provider_url'] = 'http://www.ap.org/'

  oembed['html'] = '<iframe class="ap-embed" width="100%" height="600" frameborder="0" scrolling="yes" marginheight="0" marginwidth="0" src="' + url + '"></iframe>'
  oembed['width'] = 600
  oembed['height'] = 600

  oembed
end

#handles_url?(url) ⇒ Boolean

Returns:

  • (Boolean)


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

def handles_url?(url)
  !AP_REGEX.match(url).nil?
end