Created
November 9, 2011 18:46
-
-
Save daveworth/1352484 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| [["websites", /website/i], ["emails", /email/i], ["phones", /phone|fax|cell/i]].each do |getter_data| | |
| data_type, regex = *getter_data |
wallace
commented
Nov 9, 2011
Author
SWEET!
Also something to file away .. that kind of Array structure can be easily made into a Hash with Hash.[]
ruby-1.9.2-p290 :001 > Hash[[["websites", /website/i], ["emails", /email/i], ["phones", /phone|fax|cell/i]]]
=> {"websites"=>/website/i, "emails"=>/email/i, "phones"=>/phone|fax|cell/i}
Author
AL: thanks! I knew the latter and I suppose it's almost identical to what I need to accomplish above. After converting to a hash then I can do #each and the block variables are the keys/values resp.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment