Skip to content

Instantly share code, notes, and snippets.

@Poincare
Created July 24, 2012 10:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Poincare/3169282 to your computer and use it in GitHub Desktop.
Save Poincare/3169282 to your computer and use it in GitHub Desktop.
require 'celluloid'
require 'net/http'
class MarkupPutter
include Celluloid
def initialize(url)
@url = url
end
def output(markup_future)
puts "#{@url}"
puts "#{markup_future.value}"
puts "----------------------------"
end
def get_markup
Net::HTTP.get(URI.parse(@url))
end
end
websites = ["http://google.com/", "http://yahoo.com/", "http://rubysource.com/", "http://tumblr.com/"]
websites.each do |website|
supervisor = MarkupPutter.supervise_as :mp, website
mp = Celluloid::Actor[:mp]
markup_future = mp.future :get_markup
mp.output markup_future
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment