Class: YouTubeG::Model::Video

Inherits:
Record
  • Object
show all
Defined in:
lib/youtube_g/model/video.rb

Defined Under Namespace

Classes: Format

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Record

#initialize

Constructor Details

This class inherits a constructor from YouTubeG::Record

Instance Attribute Details

#authorObject (readonly)

Returns the value of attribute author.



52
53
54
# File 'lib/youtube_g/model/video.rb', line 52

def author
  @author
end

#categoriesObject (readonly)

Returns the value of attribute categories.



48
49
50
# File 'lib/youtube_g/model/video.rb', line 48

def categories
  @categories
end

#durationObject (readonly)

Returns the value of attribute duration.



39
40
41
# File 'lib/youtube_g/model/video.rb', line 39

def duration
  @duration
end

#html_contentObject (readonly)

Returns the value of attribute html_content.



51
52
53
# File 'lib/youtube_g/model/video.rb', line 51

def html_content
  @html_content
end

#keywordsObject (readonly)

Returns the value of attribute keywords.



49
50
51
# File 'lib/youtube_g/model/video.rb', line 49

def keywords
  @keywords
end

#media_contentObject (readonly)

YouTubeG::Model::Content records describing the individual media content data available for this video. Most, but not all, videos offer this.



56
57
58
# File 'lib/youtube_g/model/video.rb', line 56

def media_content
  @media_content
end

#noembedObject (readonly)

Returns the value of attribute noembed.



40
41
42
# File 'lib/youtube_g/model/video.rb', line 40

def noembed
  @noembed
end

#player_urlObject (readonly)

Returns the value of attribute player_url.



59
60
61
# File 'lib/youtube_g/model/video.rb', line 59

def player_url
  @player_url
end

#positionObject (readonly)

Returns the value of attribute position.



41
42
43
# File 'lib/youtube_g/model/video.rb', line 41

def position
  @position
end

#published_atObject (readonly)

Returns the value of attribute published_at.



46
47
48
# File 'lib/youtube_g/model/video.rb', line 46

def published_at
  @published_at
end

#racyObject (readonly)

Returns the value of attribute racy.



42
43
44
# File 'lib/youtube_g/model/video.rb', line 42

def racy
  @racy
end

#ratingObject (readonly)

Returns the value of attribute rating.



60
61
62
# File 'lib/youtube_g/model/video.rb', line 60

def rating
  @rating
end

#statisticsObject (readonly)

Returns the value of attribute statistics.



43
44
45
# File 'lib/youtube_g/model/video.rb', line 43

def statistics
  @statistics
end

#thumbnailsObject (readonly)

YouTubeG::Model::Thumbnail records



58
59
60
# File 'lib/youtube_g/model/video.rb', line 58

def thumbnails
  @thumbnails
end

#titleObject (readonly)

Returns the value of attribute title.



50
51
52
# File 'lib/youtube_g/model/video.rb', line 50

def title
  @title
end

#updated_atObject (readonly)

Returns the value of attribute updated_at.



47
48
49
# File 'lib/youtube_g/model/video.rb', line 47

def updated_at
  @updated_at
end

#video_idObject (readonly)

Returns the value of attribute video_id.



45
46
47
# File 'lib/youtube_g/model/video.rb', line 45

def video_id
  @video_id
end

#view_countObject (readonly)

Returns the value of attribute view_count.



61
62
63
# File 'lib/youtube_g/model/video.rb', line 61

def view_count
  @view_count
end

Instance Method Details

#can_embed?Boolean

Returns:

  • (Boolean)


77
78
79
# File 'lib/youtube_g/model/video.rb', line 77

def can_embed?
  not @noembed
end

#default_media_contentObject



81
82
83
# File 'lib/youtube_g/model/video.rb', line 81

def default_media_content
  @media_content.find { |c| c.is_default? }
end

#embed_html(width = 425, height = 350) ⇒ Object



85
86
87
88
89
90
91
92
93
94
# File 'lib/youtube_g/model/video.rb', line 85

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

#embed_urlObject



96
97
98
# File 'lib/youtube_g/model/video.rb', line 96

def embed_url
  @player_url.sub('watch?', '').sub('=', '/')          
end

#unique_idObject

For convenience, the video_id with the URL stripped out, useful for searching for the video again without having to store it anywhere. A regular query search, with this id will return the same video. gdata.youtube.com/feeds/videos/ZTUVgYoeN_o



73
74
75
# File 'lib/youtube_g/model/video.rb', line 73

def unique_id
  video_id.match(/videos\/([^<]+)/).captures.first
end