Class: Onebox::Engine::YoutubeOnebox

Inherits:
Object
  • Object
show all
Includes:
Onebox::Engine, StandardEmbed
Defined in:
lib/onebox/engine/youtube_onebox.rb

Instance Attribute Summary

Attributes included from Onebox::Engine

#cache, #timeout, #url

Instance Method Summary collapse

Methods included from StandardEmbed

#raw

Methods included from Onebox::Engine

engines, included, #initialize, #placeholder_html

Instance Method Details

#append_params(html) ⇒ Object



13
14
15
16
17
18
19
20
# File 'lib/onebox/engine/youtube_onebox.rb', line 13

def append_params(html)
  result = html.dup
  result.gsub! /(src="[^"]+)/, '\1&wmode=opaque'
  if url =~ /t=(\d+)/
    result.gsub! /(src="[^"]+)/, '\1&start=' + Regexp.last_match[1]
  end
  result
end

#rewrite_agnostic(html) ⇒ Object



22
23
24
# File 'lib/onebox/engine/youtube_onebox.rb', line 22

def rewrite_agnostic(html)
  html.gsub(/https?:\/\//, '//')
end

#to_htmlObject



9
10
11
# File 'lib/onebox/engine/youtube_onebox.rb', line 9

def to_html
  rewrite_agnostic(append_params(raw[:html]))
end