Skip to content

Instantly share code, notes, and snippets.

@tyok
Last active November 1, 2017 09:01
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 tyok/374956d05dad4c77e3e25e3987855193 to your computer and use it in GitHub Desktop.
Save tyok/374956d05dad4c77e3e25e3987855193 to your computer and use it in GitHub Desktop.
Ruby method chain
sample_text = "foo bar http://github.com/akitaonrails/chainable_methods foo bar"
sample_link = URI.extract(sample_text).first
uri = URI.parse(sample_link)
response = HTTParty.get(uri)
doc = Nokogiri::HTML.parse(response)
title = doc.css("H1").text
v = "foo bar http://github.com/akitaonrails/chainable_methods foo bar"
v = URI.extract(v).first
v = URI.parse(v)
v = HTTParty.get(v)
v = Nokogiri::HTML.parse(v)
v = v.css("H1").text
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment