Guest User

Untitled

a guest
May 26th, 2016
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.28 KB | None | 0 0
  1. # Determine whether a string contains a SIN (Social Insurance Number).
  2. # A SIN is 9 digits and we are assuming that they must have dashes in them
  3. def has_sin?(string)
  4. end
  5.  
  6. puts "has_sin? returns true if it has what looks like a SIN"
  7. puts has_sin?("please don't share this: 234-604-142") == true
  8.  
  9. puts "has_sin? returns false if it doesn't have a SIN"
  10. puts has_sin?("please confirm your identity: XXX-XXX-142") == false
  11. puts has_sin?("please don't share this: 234-6043-142") == false
  12. puts has_sin?("please don't share this: 2342-604-142") == false
  13. puts has_sin?("please don't share this: 234-604-1421") == false
  14.  
  15. # Return the Social Insurance Number from a string.
  16. def grab_sin(string)
  17. end
  18.  
  19.  
  20. puts "grab_sin returns an SIN if the string has an SIN"
  21. puts grab_sin("please don't share this: 234-604-142") == "234-604-142"
  22.  
  23. puts "grab_sin returns nil if it doesn't have a SIN"
  24. puts grab_sin("please confirm your identity: XXX-XXX-142") == nil
  25.  
  26.  
  27. # Return all of the SINs from a string, not just one.
  28. def grab_all_sins(string)
  29. end
  30.  
  31. puts "grab_all_sins returns all SINs if the string has any SINs"
  32. puts grab_all_sins("234-604-142, 350-802-074, 013-630-876") == ["234-604-142", "350-802-074", "013-630-876"]
  33.  
  34. puts "grab_all_sins returns an empty Array if it doesn't have any SINs"
  35. puts grab_all_sins("please confirm your identity: XXX-XXX-142") == []
  36.  
  37.  
  38. # Obfuscate all of the Social Insurance numbers in a string. Example: XXX-XX-4430.
  39. def hide_all_sins(string)
  40. end
  41.  
  42. puts "hide_all_sins obfuscates any SINs in the string"
  43. puts hide_all_sins("234-601-142, 350-801-074, 013-601-876") == "XXX-XXX-142, XXX-XXX-074, XXX-XXX-876"
  44.  
  45. puts "hide_all_sins does not alter a string without SINs in it"
  46. string = "please confirm your identity: XXX-XXX-142"
  47. puts hide_all_sins(string) == string
  48.  
  49.  
  50. # Ensure all of the Social Insurance numbers use dashes for delimiters.
  51. # Example: 480.01.4430 and 480014430 would both be 480-01-4430.
  52. def format_sins(string)
  53. end
  54.  
  55. puts "format_sins finds and reformat any SINs in the string"
  56. puts format_sins("234600142, 350.800.074, 013-600-876") == "234-600-142, 350-800-074, 013-600-876"
  57.  
  58. puts "format_sins does not alter a string without SINs in it"
  59. string = "please confirm your identity: 4421422"
  60. puts format_sins(string) == string
  61.  
  62. string = "please confirm your identity: 123abc445"
  63. puts format_sins(string) == string
Add Comment
Please, Sign In to add comment