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_seconds ⇒ Object
readonly
Returns the value of attribute length_seconds.
-
#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.
291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 |
# 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 |
Instance Attribute Details
#author ⇒ Object (readonly)
Returns the value of attribute author.
276 277 278 |
# File 'lib/youtube.rb', line 276 def @author end |
#comment_count ⇒ Object (readonly)
Returns the value of attribute comment_count.
277 278 279 |
# File 'lib/youtube.rb', line 277 def comment_count @comment_count end |
#description ⇒ Object (readonly)
Returns the value of attribute description.
278 279 280 |
# File 'lib/youtube.rb', line 278 def description @description end |
#embed_url ⇒ Object (readonly)
Returns the value of attribute embed_url.
279 280 281 |
# File 'lib/youtube.rb', line 279 def @embed_url end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
280 281 282 |
# File 'lib/youtube.rb', line 280 def id @id end |
#length_seconds ⇒ Object (readonly)
Returns the value of attribute length_seconds.
281 282 283 |
# File 'lib/youtube.rb', line 281 def length_seconds @length_seconds end |
#rating_avg ⇒ Object (readonly)
Returns the value of attribute rating_avg.
282 283 284 |
# File 'lib/youtube.rb', line 282 def @rating_avg end |
#rating_count ⇒ Object (readonly)
Returns the value of attribute rating_count.
283 284 285 |
# File 'lib/youtube.rb', line 283 def @rating_count end |
#tags ⇒ Object (readonly)
Returns the value of attribute tags.
284 285 286 |
# File 'lib/youtube.rb', line 284 def @tags end |
#thumbnail_url ⇒ Object (readonly)
Returns the value of attribute thumbnail_url.
285 286 287 |
# File 'lib/youtube.rb', line 285 def thumbnail_url @thumbnail_url end |
#title ⇒ Object (readonly)
Returns the value of attribute title.
286 287 288 |
# File 'lib/youtube.rb', line 286 def title @title end |
#upload_time ⇒ Object (readonly)
Returns the value of attribute upload_time.
287 288 289 |
# File 'lib/youtube.rb', line 287 def upload_time @upload_time end |
#url ⇒ Object (readonly)
Returns the value of attribute url.
288 289 290 |
# File 'lib/youtube.rb', line 288 def url @url end |
#view_count ⇒ Object (readonly)
Returns the value of attribute view_count.
289 290 291 |
# File 'lib/youtube.rb', line 289 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.
315 316 317 318 319 320 321 322 323 324 |
# File 'lib/youtube.rb', line 315 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 |