Class: YouTube::Video
- Inherits:
-
Object
- Object
- YouTube::Video
- Defined in:
- lib/youtube.rb
Instance Attribute Summary collapse
-
#author ⇒ Object
readonly
Returns the value of attribute author.
-
#comment_count ⇒ Object
readonly
Returns the value of attribute comment_count.
-
#description ⇒ Object
readonly
Returns the value of attribute description.
-
#embed_url ⇒ Object
readonly
Returns the value of attribute embed_url.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#length ⇒ Object
readonly
Returns the value of attribute length.
-
#rating_avg ⇒ Object
readonly
Returns the value of attribute rating_avg.
-
#rating_count ⇒ Object
readonly
Returns the value of attribute rating_count.
-
#tags ⇒ Object
readonly
Returns the value of attribute tags.
-
#thumbnail_url ⇒ Object
readonly
Returns the value of attribute thumbnail_url.
-
#title ⇒ Object
readonly
Returns the value of attribute title.
-
#upload_time ⇒ Object
readonly
Returns the value of attribute upload_time.
-
#url ⇒ Object
readonly
Returns the value of attribute url.
-
#view_count ⇒ Object
readonly
Returns the value of attribute view_count.
Instance Method Summary collapse
-
#embed_html(width = 425, height = 350) ⇒ Object
Returns HTML analogous to that provided by the YouTube web site to allow for easy embedding of this video in a web page.
-
#initialize(payload) ⇒ Video
constructor
A new instance of Video.
Constructor Details
#initialize(payload) ⇒ Video
Returns a new instance of Video.
212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 |
# File 'lib/youtube.rb', line 212 def initialize(payload) @author = payload['author'] @comment_count = payload['comment_count'].to_i @description = payload['description'] @id = payload['id'] @length = payload['length'] @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'] @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 |
Instance Attribute Details
#author ⇒ Object (readonly)
Returns the value of attribute author.
197 198 199 |
# File 'lib/youtube.rb', line 197 def @author end |
#comment_count ⇒ Object (readonly)
Returns the value of attribute comment_count.
198 199 200 |
# File 'lib/youtube.rb', line 198 def comment_count @comment_count end |
#description ⇒ Object (readonly)
Returns the value of attribute description.
199 200 201 |
# File 'lib/youtube.rb', line 199 def description @description end |
#embed_url ⇒ Object (readonly)
Returns the value of attribute embed_url.
200 201 202 |
# File 'lib/youtube.rb', line 200 def @embed_url end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
201 202 203 |
# File 'lib/youtube.rb', line 201 def id @id end |
#length ⇒ Object (readonly)
Returns the value of attribute length.
202 203 204 |
# File 'lib/youtube.rb', line 202 def length @length end |
#rating_avg ⇒ Object (readonly)
Returns the value of attribute rating_avg.
203 204 205 |
# File 'lib/youtube.rb', line 203 def @rating_avg end |
#rating_count ⇒ Object (readonly)
Returns the value of attribute rating_count.
204 205 206 |
# File 'lib/youtube.rb', line 204 def @rating_count end |
#tags ⇒ Object (readonly)
Returns the value of attribute tags.
205 206 207 |
# File 'lib/youtube.rb', line 205 def @tags end |
#thumbnail_url ⇒ Object (readonly)
Returns the value of attribute thumbnail_url.
206 207 208 |
# File 'lib/youtube.rb', line 206 def thumbnail_url @thumbnail_url end |
#title ⇒ Object (readonly)
Returns the value of attribute title.
207 208 209 |
# File 'lib/youtube.rb', line 207 def title @title end |
#upload_time ⇒ Object (readonly)
Returns the value of attribute upload_time.
208 209 210 |
# File 'lib/youtube.rb', line 208 def upload_time @upload_time end |
#url ⇒ Object (readonly)
Returns the value of attribute url.
209 210 211 |
# File 'lib/youtube.rb', line 209 def url @url end |
#view_count ⇒ Object (readonly)
Returns the value of attribute view_count.
210 211 212 |
# File 'lib/youtube.rb', line 210 def view_count @view_count end |
Instance Method Details
#embed_html(width = 425, height = 350) ⇒ Object
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.
236 237 238 239 240 241 242 243 244 245 |
# File 'lib/youtube.rb', line 236 def (width = 425, height = 350) <<edoc <object width="#{width}" height="#{height}"> <param name="movie" value="#{}"></param> <param name="wmode" value="transparent"></param> <embed src="#{}" type="application/x-shockwave-flash" wmode="transparent" width="#{width}" height="#{height}"></embed> </object> edoc end |