Class: VideoEmbed::YouTube::Url

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(url, options = {}) ⇒ Url

Returns a new instance of Url.



17
18
19
20
21
# File 'lib/video_embed/youtube.rb', line 17

def initialize(url, options = {})
  @url = url
  @width = options.fetch(:width, 560)
  @height = options.fetch(:height, 315)
end

Instance Attribute Details

#heightObject (readonly)

Returns the value of attribute height.



15
16
17
# File 'lib/video_embed/youtube.rb', line 15

def height
  @height
end

#urlObject (readonly)

Returns the value of attribute url.



15
16
17
# File 'lib/video_embed/youtube.rb', line 15

def url
  @url
end

#widthObject (readonly)

Returns the value of attribute width.



15
16
17
# File 'lib/video_embed/youtube.rb', line 15

def width
  @width
end

Instance Method Details

#embedObject



23
24
25
# File 'lib/video_embed/youtube.rb', line 23

def embed
  %Q{<iframe width="#{width}" height="#{height}" src="http://www.youtube.com/embed/#{video_id}?rel=0" frameborder="0" allowfullscreen></iframe>}
end