Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 4th, 2012  |  syntax: None  |  size: 0.35 KB  |  hits: 10  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. require 'rubygems'
  2. require 'eventmachine'
  3. require 'em-http-request'
  4.  
  5. EM.run do
  6.   def foo
  7.     http = EM::HttpRequest.new('http://www.google.com').get
  8.     http.callback do |get|
  9.       get.response
  10.     end
  11.   end
  12.  
  13.   puts foo # A Proc
  14.   fail "didn't work" if !foo.include?("<!doctype html>")
  15.   # foo is returning a Proc, I want it to return the http response.
  16. end