Skip to content

Instantly share code, notes, and snippets.

@bradbergeron-us
Created May 29, 2015 06:50
Show Gist options
  • Save bradbergeron-us/691a01be8d51bf949972 to your computer and use it in GitHub Desktop.
Save bradbergeron-us/691a01be8d51bf949972 to your computer and use it in GitHub Desktop.
backtick overriding
# backtick is a kernel operation in Ruby
# which mean it can be overridden
# backtick method is called on the implicit receiver (that is, “self”). That means that you # can do this:
'''
#! bin/env ruby
require 'net/http'
class Google
include BacktickURI
def search_page_html
url = `http://www.google.com/`
res = Net::HTTP.start(url.host, url.port) {|http|
http.get('/')
}
res.body
end
end
'''
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment