Class: Videodrome::Video

Inherits:
Object
  • Object
show all
Defined in:
lib/videodrome/video.rb

Overview

Video wrapper for Youtube info

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of Video.



9
10
11
12
13
14
# File 'lib/videodrome/video.rb', line 9

def initialize(url, options = {})
  @url = URL.new(url)
  @id = @url.id
  @raw_data = Videodrome.connection.get(options.merge(:id => @id))
  parse_raw_data
end

Instance Attribute Details

#detailsObject (readonly)

Returns the value of attribute details.



7
8
9
# File 'lib/videodrome/video.rb', line 7

def details
  @details
end

#idObject (readonly)

Returns the value of attribute id.



7
8
9
# File 'lib/videodrome/video.rb', line 7

def id
  @id
end

#playerObject (readonly)

Returns the value of attribute player.



7
8
9
# File 'lib/videodrome/video.rb', line 7

def player
  @player
end

#raw_dataObject (readonly)

Returns the value of attribute raw_data.



7
8
9
# File 'lib/videodrome/video.rb', line 7

def raw_data
  @raw_data
end

#snippetObject (readonly)

Returns the value of attribute snippet.



7
8
9
# File 'lib/videodrome/video.rb', line 7

def snippet
  @snippet
end

#statusObject (readonly)

Returns the value of attribute status.



7
8
9
# File 'lib/videodrome/video.rb', line 7

def status
  @status
end

Instance Method Details

#descriptionObject



24
25
26
# File 'lib/videodrome/video.rb', line 24

def description
  snippet.description
end

#durationObject



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

def duration
  details.duration
end

#embed_htmlObject



36
37
38
# File 'lib/videodrome/video.rb', line 36

def embed_html
  player.embedHtml if embeddable
end

#embeddableObject



44
45
46
# File 'lib/videodrome/video.rb', line 44

def embeddable
  status.embeddable
end

#published_atObject



16
17
18
# File 'lib/videodrome/video.rb', line 16

def published_at
  Time.iso8601(snippet.publishedAt)
end

#thumbnail(size = "standard") ⇒ Object



32
33
34
# File 'lib/videodrome/video.rb', line 32

def thumbnail(size = "standard")
  thumbnails[size]
end

#thumbnailsObject



28
29
30
# File 'lib/videodrome/video.rb', line 28

def thumbnails
  snippet.thumbnails
end

#titleObject



20
21
22
# File 'lib/videodrome/video.rb', line 20

def title
  snippet.title
end