Skip to content

Instantly share code, notes, and snippets.

@thiagovsk
Created December 20, 2016 17:56
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 thiagovsk/617672795dc5288def944e81cebdc46a to your computer and use it in GitHub Desktop.
Save thiagovsk/617672795dc5288def944e81cebdc46a to your computer and use it in GitHub Desktop.
def parse_wads(wads, content = {})
unless wads.empty?
wads.each_with_index do |item, index|
if item['text']
scan = item['text'].gsub('\\n', '\n').match(/(?:\s|^)(\S+)@$/m)
if scan && wads[index + 1]
text = wads[index + 1]['text']
content[:email] = scan.to_s.strip.downcase
content[:email] << text if text
end
end
end
end
content
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment