Class: YouTube

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

Instance Method Summary collapse

Constructor Details

#initialize(identifier) ⇒ YouTube

Returns a new instance of YouTube.



6
7
8
9
10
# File 'lib/youtube.rb', line 6

def initialize identifier
  @id = find_id(identifier)

  @meta = nil
end

Instance Method Details

#hrefObject



17
18
19
# File 'lib/youtube.rb', line 17

def href
  "http://www.youtube.com/watch?v=#{@id}"
end

#idObject



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

def id
  @id
end

#tags(uri) ⇒ Object



21
22
23
24
25
26
27
28
29
# File 'lib/youtube.rb', line 21

def tags(uri)
  parse

  thumbs = get_thumbs.map do |key,thumb|
    uri.path = thumb.uri_path
    [key, %Q{<a href="#{href}"><img src="#{uri}" alt="#{title}"/></a>}]
  end
  Hash[thumbs]
end

#titleObject



12
13
14
15
# File 'lib/youtube.rb', line 12

def title
  parse
  @meta.title
end

#valid?Boolean

Returns:

  • (Boolean)


31
32
33
34
# File 'lib/youtube.rb', line 31

def valid?
  parse
  not @meta.title.nil?
end