Guest User

Untitled

a guest
Jun 19th, 2018
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1. raw_html = resp.body.grep(/(?:e|dn)lk[0-9]+/)
  2. raw_html.delete_at 0
  3. raw_html.inject do |memo, row|
  4. c_info = row.match(/(e|dn)lk([0-9])+/)
  5.  
  6. # Same contact, or different?
  7. build_contacts << [] if memo != c_info[2]
  8.  
  9. # Grab info
  10. case c_info[1]
  11. when "e" # Email
  12. build_contacts.last[1] = row.match(/#{email_match_text_beginning}(.*)#{email_match_text_end}/)[1]
  13. when "dn" # Name
  14. build_contacts.last[0] = row.match(/<a[^>]*>(.+)<\/a>/)[1]
  15. end
  16.  
  17. # Set memo to contact id
  18. c_info[2]
  19. end
Add Comment
Please, Sign In to add comment