class YouTube::Video

Attributes

author[R]
comment_count[R]
description[R]
embed_url[R]
id[R]
length_seconds[R]
rating_avg[R]
rating_count[R]
tags[R]
thumbnail_url[R]
title[R]
upload_time[R]
url[R]
view_count[R]

Public Instance Methods

embed_html(width = 425, height = 350) click to toggle source

Returns HTML analogous to that provided by the YouTube web site to allow for easy embedding of this video in a web page. Optional width and height parameters allow specifying the dimensions of the video for display.

# File lib/youtube.rb, line 315
    def embed_html(width = 425, height = 350)
      <<edoc
<object width="#{width}" height="#{height}">
  <param name="movie" value="#{embed_url}"></param>
  <param name="wmode" value="transparent"></param>
  <embed src="#{embed_url}" type="application/x-shockwave-flash" 
   wmode="transparent" width="#{width}" height="#{height}"></embed>
</object>
edoc
    end

Public Class Methods

new(payload) click to toggle source
# File lib/youtube.rb, line 291
def initialize(payload)
  @author = payload['author'].to_s
  @comment_count = payload['comment_count'].to_i
  @description = payload['description'].to_s
  @id = payload['id']
  @length_seconds = payload['length_seconds'].to_i
  @rating_avg = payload['rating_avg'].to_f
  @rating_count = payload['rating_count'].to_i
  @tags = payload['tags']
  @thumbnail_url = payload['thumbnail_url']
  @title = payload['title'].to_s
  @upload_time = YouTube._string_to_time(payload['upload_time'])
  @url = payload['url']
  @view_count = payload['view_count'].to_i

  # the url provided via the API links to the video page -- for
  # convenience, generate the url used to embed in a page
  @embed_url = @url.delete('?').sub('=', '/')
end