Class: YouTube
- Inherits:
-
Object
- Object
- YouTube
- Defined in:
- lib/youtube.rb
Instance Method Summary collapse
- #href ⇒ Object
- #id ⇒ Object
-
#initialize(identifier) ⇒ YouTube
constructor
A new instance of YouTube.
- #tags(uri) ⇒ Object
- #title ⇒ Object
- #valid? ⇒ Boolean
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
#href ⇒ Object
17 18 19 |
# File 'lib/youtube.rb', line 17 def href "http://www.youtube.com/watch?v=#{@id}" end |
#id ⇒ Object
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 (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 |
#title ⇒ Object
12 13 14 15 |
# File 'lib/youtube.rb', line 12 def title parse @meta.title end |
#valid? ⇒ Boolean
31 32 33 34 |
# File 'lib/youtube.rb', line 31 def valid? parse not @meta.title.nil? end |