Class: EmbeddedURL::Youtube

Inherits:
Object
  • Object
show all
Defined in:
lib/embedded_url/youtube.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(url) ⇒ Youtube

Returns a new instance of Youtube.



6
7
8
# File 'lib/embedded_url/youtube.rb', line 6

def initialize(url)
  self.url = url
end

Instance Attribute Details

#urlObject

Returns the value of attribute url.



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

def url
  @url
end

Instance Method Details

#to_embeddedObject



10
11
12
13
14
15
16
# File 'lib/embedded_url/youtube.rb', line 10

def to_embedded
  if url =~ /youtube\.com/
    video_id = url.split("v=").last
    "<object width=\"400\" height=\"325\"><param name=\"movie\" value=\"http://www.youtube.com/v/#{video_id}\"></param><param name=\"allowFullScreen\" value=\"true\"></param><embed src=\"http://www.youtube.com/v/#{video_id}\" type=\"application/x-shockwave-flash\" allowfullscreen=\"true\" width=\"400\" height=\"325\"></embed></object>"
  end
  
end