Ben Giddings
3/7/2005 6:20:00 PM
Hi, I found a few ways to improve your program.
--- tokyo_job.rb.orig 2005-03-07 12:41:23.457936200 -0500
+++ tokyo_job.rb 2005-03-07 13:16:14.736811208 -0500
@@ -101,11 +102,11 @@
applicant.location = gets.chomp
note = " [One entry per line. Press CTRL-D to stop input] "
puts "What languages do you speak?", note
- applicant.spoken_languages = readlines.map { |d| d.chomp }
+ applicant.spoken_languages = readlines.map { |d| d.downcase.chomp }
cq1 = "What computer languages are you proficient in?"
cq2 = "And what other computer skills do you have?"
puts cq1, cq2, note
- applicant.computer_languages_skills = readlines.map {|d| d.chomp }
+ applicant.computer_languages_skills = readlines.map {|d|
d.downcase.chomp }
puts ""
applicant
end
@@ -157,42 +158,55 @@
reqs = Array.new
reqs<< Requirement.new(25) do |ja|
- ja.spoken_languages.include?("English")
+ ja.spoken_languages.include?("english")
end
reqs<< Requirement.new(25) do |ja|
- ja.spoken_languages.include?("Japanese")
+ ja.spoken_languages.include?("japanese")
end
reqs<< Requirement.new(5) do |ja|
- sub = ["English", "Japanese"]
+ sub = ["english", "japanese"]
(ja.spoken_languages - sub).size > 0
end
reqs<< Requirement.new(50) do |ja|
- ja.computer_languages_skills.include?("Ruby")
+ ja.computer_languages_skills.include?("ruby")
end
reqs<< Requirement.new(25) do |ja|
- ja.computer_languages_skills.include?("Databases")
+ ja.computer_languages_skills.grep(/database/).size > 0 or
+ ja.computer_languages_skills.grep(/\bdb\b/).size > 0
+ ja.computer_languages_skills.grep(/sql/).size > 0
end
reqs<< Requirement.new(10) do |ja|
- ja.computer_languages_skills.include?("Mobile Technologies")
+ ja.computer_languages_skills.include?("mobile technologies")
end
reqs<< Requirement.new(5) do |ja|
- ja.computer_languages_skills.include?("*NIX")
+ ja.computer_languages_skills.grep(/linux|unix/).size > 0
end
reqs<< Requirement.new(5) do |ja|
- (ja.computer_languages_skills - ["Ruby", "Database"]).size > 0
+ ja.computer_languages_skills.find_all do |lang|
+ case lang
+ when /ruby/, /database/, /\bdb\b/, /sql/
+ false
+ else
+ true
+ end
+ end.size > 0
end
reqs<< Requirement.new(25) do |ja|
ja.location =~ /Japan/i
end
+reqs<< Requirement.new(5) do |ja|
+ ja.name =~ /Ben/i
+end
+
developer.requirements = reqs
developer.threshold = 125
With these changes, it doesn't require '*NIX', but will accept "Linux"
or "Unix", and it is a bit more accepting of various database keywords.
(Oh yeah, and it assigns bonus points for cool names)
Ben
(P.S. !Japan, !Japanese, !"Mobile Technologies", and !currently_looking?
but that was too much fun to pass up. :) )