Skip to content

Instantly share code, notes, and snippets.

@hashrocketeer
Created January 21, 2013 22:57
Show Gist options
  • Save hashrocketeer/4590301 to your computer and use it in GitHub Desktop.
Save hashrocketeer/4590301 to your computer and use it in GitHub Desktop.
module TabularSupport
def hashes_from_table
actual = find("table")
headers = actual.all("th").map(&:text)
actual.all("tbody tr").map do |row|
Hash[headers.zip row.all("td").map(&:text).compact.map(&:strip)]
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment