Class: VgTed
Instance Method Summary collapse
- #download_url ⇒ Object
- #duration ⇒ Object
- #embed_html(width = 425, height = 344, options = {}) ⇒ Object
- #embed_url ⇒ Object
- #flv ⇒ Object
-
#initialize(url = nil, options = {}) ⇒ VgTed
constructor
A new instance of VgTed.
- #service ⇒ Object
- #thumbnail ⇒ Object
- #title ⇒ Object
Constructor Details
#initialize(url = nil, options = {}) ⇒ VgTed
Returns a new instance of VgTed.
9 10 11 12 13 14 15 16 17 |
# File 'lib/acts_as_unvlogable/vg_ted.rb', line 9 def initialize(url=nil, ={}) @url = url raise unless URI::parse(url).path.split("/").include? "talks" @page = Hpricot(open(url)) id = @page.to_s.split("/id/")[1].split("\"")[0] @emb = Hpricot(open("http://www.ted.com/talks/embed/id/#{id}")) @flashvars = CGI::unescapeHTML(@emb.to_s).split("param name=\"flashvars\" value=\"")[1].split("\"")[0] @args = CGI::parse(@flashvars) end |
Instance Method Details
#download_url ⇒ Object
43 44 45 |
# File 'lib/acts_as_unvlogable/vg_ted.rb', line 43 def download_url nil end |
#duration ⇒ Object
27 28 29 |
# File 'lib/acts_as_unvlogable/vg_ted.rb', line 27 def duration nil end |
#embed_html(width = 425, height = 344, options = {}) ⇒ Object
35 36 37 |
# File 'lib/acts_as_unvlogable/vg_ted.rb', line 35 def (width=425, height=344, ={}) "<object width='#{width}' height='#{height}'><param name='movie' value='#{}'></param><param name='allowFullScreen' value='true' /><param name='wmode' value='transparent'></param><param name='bgColor' value='#ffffff'></param><embed src='#{}' pluginspace='http://www.macromedia.com/go/getflashplayer' type='application/x-shockwave-flash' wmode='transparent' bgColor='#ffffff' width='#{width}' height='#{height}' allowFullScreen='true'></embed></object>" end |
#embed_url ⇒ Object
31 32 33 |
# File 'lib/acts_as_unvlogable/vg_ted.rb', line 31 def "http://video.ted.com/assets/player/swf/EmbedPlayer.swf?#{@flashvars}" end |
#flv ⇒ Object
39 40 41 |
# File 'lib/acts_as_unvlogable/vg_ted.rb', line 39 def flv "#{@args['vu'].to_s}" end |
#service ⇒ Object
47 48 49 |
# File 'lib/acts_as_unvlogable/vg_ted.rb', line 47 def service "Ted Talks" end |
#thumbnail ⇒ Object
23 24 25 |
# File 'lib/acts_as_unvlogable/vg_ted.rb', line 23 def thumbnail "#{@args['su']}" end |
#title ⇒ Object
19 20 21 |
# File 'lib/acts_as_unvlogable/vg_ted.rb', line 19 def title @page.search("//h1/span").first.inner_html.strip end |