Guest User

Untitled

a guest
Jul 16th, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.09 KB | None | 0 0
  1. # In this file we define the methods to help filter out candidates
  2. # This way, we keep these methods separated from other potential parts of the program
  3.  
  4. def find(id)
  5. @candidates.each do |candidate|
  6. if candidate[:id] == id
  7. return candidate
  8. end
  9. end
  10. return nil
  11. end
  12.  
  13. def experienced?(candidate)
  14. if candidate[:years_of_experience] >= 2
  15. return true
  16. else
  17. return false
  18. end
  19.  
  20. end
  21.  
  22. def qualified_candidates(candidates)
  23. qualifiedCandidates = []
  24. candidates.each do |candidate|
  25. todaysJDate = DateTime.parse(Time.now.to_s).jd
  26. appliedJDate = candidate[:date_applied].jd
  27. daysElapsed = todaysJDate - appliedJDate
  28. if experienced?(candidate) &&
  29. candidate[:github_points] >= 100 &&
  30. candidate[:languages].include?('Python') &&
  31. candidate[:languages].include?('Ruby') &&
  32. daysElapsed <= 15 &&
  33. candidate[:age] > 17
  34. then
  35. qualifiedCandidates.push(candidate)
  36. end
  37. end
  38. return qualifiedCandidates
  39. end
  40.  
  41. def sortByExperience(candidates)
  42. return candidates.sort_by {|candidate| [-candidate[:years_of_experience], -candidate[:github_points]] }
  43. end
Add Comment
Please, Sign In to add comment