Skip to content

Instantly share code, notes, and snippets.

@gmanley
Created April 23, 2012 07:11
Show Gist options
  • Save gmanley/2469307 to your computer and use it in GitHub Desktop.
Save gmanley/2469307 to your computer and use it in GitHub Desktop.
Regexp MatchData to_hash monkey patch
class MatchData
def to_hash
Hash[[names, captures].transpose]
end
alias :to_h :to_hash
end
@michaeljbishop
Copy link

If you are busy, I could add it if you like, giving you full credit and including a unit-test (I already wrote one)

@michaeljbishop
Copy link

I used it in conjuction with Facet's Hash#symbolize_keys

@gmanley
Copy link
Author

gmanley commented May 31, 2012

Nice, go for it, that'd be great. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment