Class: Video::Youtube

Inherits:
Video
  • Object
show all
Defined in:
lib/videoclip/videos/youtube.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.match?(uri) ⇒ Boolean

Returns:

  • (Boolean)


4
5
6
# File 'lib/videoclip/videos/youtube.rb', line 4

def self.match?(uri)
  (uri.host =~ /^(?:www\.)?youtube\.com$/i) && (uri.path == '/watch') && !CGI.parse(uri.query)['v'].blank?
end

Instance Method Details

#assign(uri) ⇒ Object



8
9
10
11
# File 'lib/videoclip/videos/youtube.rb', line 8

def assign(uri)
  @key = CGI.parse(uri.query)['v'].first
  @url = "http://www.youtube.com/watch?v=#{@key}"
end

#embed(style = nil) ⇒ Object



13
14
15
# File 'lib/videoclip/videos/youtube.rb', line 13

def embed(style = nil)
  %(<object width="#{width(style)}" height="#{height(style)}"><param name="movie" value="http://www.youtube.com/v/#{key}&hl=en&fs=1"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/#{key}&hl=en&fs=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="#{width(style)}" height="#{height(style)}"></embed></object>)
end