Module: Comedy

Defined in:
lib/comedy.rb,
lib/comedy/version.rb

Constant Summary collapse

VERSION =
'0.1.2'

Class Method Summary collapse

Class Method Details

.laugh_with(man) ⇒ Object



14
15
16
# File 'lib/comedy.rb', line 14

def self.laugh_with(man)
	Launchy.open("http://www.youtube.com/#{search(man)}")
end

.search(star) ⇒ Object



4
5
6
7
8
9
10
11
12
# File 'lib/comedy.rb', line 4

def self.search(star)
	agent = Mechanize.new
	page = []
	    (1..5).each do |i|
	        page += agent.get("http://www.youtube.com/results?search_query=comedy+#{star}&page=#{i}").links_with(:href => /watch/)
	    end
	link = page[rand(page.length)].uri.to_s
  return link
end