Class: VgTed

Inherits:
Object show all
Defined in:
lib/acts_as_unvlogable/vg_ted.rb

Instance Method Summary collapse

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, options={})
  @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_urlObject



43
44
45
# File 'lib/acts_as_unvlogable/vg_ted.rb', line 43

def download_url
  nil
end

#durationObject



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 embed_html(width=425, height=344, options={})
  "<object width='#{width}' height='#{height}'><param name='movie' value='#{embed_url}'></param><param name='allowFullScreen' value='true' /><param name='wmode' value='transparent'></param><param name='bgColor' value='#ffffff'></param><embed src='#{embed_url}' 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_urlObject



31
32
33
# File 'lib/acts_as_unvlogable/vg_ted.rb', line 31

def embed_url
    "http://video.ted.com/assets/player/swf/EmbedPlayer.swf?#{@flashvars}"
end

#flvObject



39
40
41
# File 'lib/acts_as_unvlogable/vg_ted.rb', line 39

def flv
  "#{@args['vu'].to_s}"
end

#serviceObject



47
48
49
# File 'lib/acts_as_unvlogable/vg_ted.rb', line 47

def service
  "Ted Talks"
end

#thumbnailObject



23
24
25
# File 'lib/acts_as_unvlogable/vg_ted.rb', line 23

def thumbnail
  "#{@args['su']}"
end

#titleObject



19
20
21
# File 'lib/acts_as_unvlogable/vg_ted.rb', line 19

def title
  @page.search("//h1/span").first.inner_html.strip
end