Skip to content

Instantly share code, notes, and snippets.

@hackervera
Created September 22, 2010 04:47
Show Gist options
  • Select an option

  • Save hackervera/591158 to your computer and use it in GitHub Desktop.

Select an option

Save hackervera/591158 to your computer and use it in GitHub Desktop.
require 'rubygems'
require 'httparty'
require 'json'
obj = {
:addOne => lambda {|x| x+1},
:face => "happy",
:getSite => lambda {|url| HTTParty.get(url)},
:parseJson => lambda {|url| JSON.parse(HTTParty.get(url))}
}
puts obj[:addOne].call(5) #=> 5
puts obj[:face] #=> happy
puts obj[:getSite].call("http://www.google.com")
puts obj[:parseJson].call("http://tyler.couchone.com/")["version"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment