Skip to content

Instantly share code, notes, and snippets.

@gorsuch
Created January 2, 2013 18:53
Show Gist options
  • Save gorsuch/4436860 to your computer and use it in GitHub Desktop.
Save gorsuch/4436860 to your computer and use it in GitHub Desktop.
String#scan is awesome.
line = "measure=foo.bar value=0.123123 timestamp=1231235"
line.scan(/(\S+)=(\S+)/i).map { |x| Hash[*x] }.inject({}) { |h,x| h.merge(x) }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment