[Job] Ruby Developers in Tokyo, Japan

Discussion in 'Ruby' started by Zev Blut, Mar 7, 2005.

  1. Zev Blut

    Zev Blut Guest

    #!/usr/bin/env ruby

    # Warning this is a job announcement!
    # Run it/Read it if you are interested.
    # Lack of comments and robust input handling are intentional.

    class Company
    attr_accessor :name, :location, :web_site, :description
    attr_accessor :available_jobs

    def initialize(name = nil, location = nil, web_site = nil)
    self.name = name
    self.location = location
    self.web_site = web_site
    self.available_jobs = Array.new
    end

    def ask_for_interview?(job_applicant)
    available_jobs.each do |ajob|
    return true if ajob.meets_requirements?(job_applicant)
    end
    false
    end

    def describe
    puts "Company : #{name}"
    puts "Location : #{location}"
    puts "Web site : #{web_site}"
    puts "","Brief description :"
    puts description, ""
    end

    def announce_job_availability(good_match, not_so_good_match)
    return if available_jobs.empty?
    describe
    puts "Available jobs:"
    available_jobs.each_with_index do |job, idx|
    puts "", "#{idx + 1} ) #{job.name}", job.description, ""
    end

    job_applicant = ask_for_job_applicant_information
    return if job_applicant.nil?

    if ask_for_interview?( job_applicant )
    puts good_match
    else
    puts not_so_good_match
    end
    end

    def ask_for_job_applicant_information
    job_applicant = nil
    puts "Would you like to apply for a job? Y/N"
    res = gets.chomp
    if res =~ /Y/i
    msg = "Great! Please follow the prompts to input your profile"
    msg<< " to see if there if a job matches."
    puts msg, ""
    job_applicant = JobApplicant.new_from_interactive_shell
    else
    puts "Well thanks for reading/running the program! Good Bye!"
    end
    job_applicant
    end

    end

    class Job
    attr_accessor :name, :description, :requirements, :threshold
    def initialize(name = nil, description = nil,
    threshold = 100, requirements = [] )
    self.name = name
    self.description = description
    self.requirements = requirements
    self.threshold = threshold
    end

    def meets_requirements?(job_applicant)
    points = 0
    requirements.each do |req|
    points += req.check_requirement(job_applicant)
    end
    points >= threshold
    end

    end

    class JobApplicant
    attr_accessor :name, :resume, :location
    attr_accessor :spoken_languages, :computer_languages_skills
    def initialize
    self.spoken_languages = Array.new
    self.computer_languages_skills = Array.new
    end

    def JobApplicant.new_from_interactive_shell
    applicant = JobApplicant.new
    puts "What is your name?"
    applicant.name = gets.chomp
    puts "Where do you live? (City, Country)"
    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 }
    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 }
    puts ""
    applicant
    end

    end

    class Requirement

    def initialize(points = 1, &proc)
    @points = points
    if proc
    @requirement_calc = proc
    else
    @requirement_calc = Proc.new { |x| true }
    end
    end

    def check_requirement(job_applicant)
    points = 0
    if @requirement_calc.call(job_applicant)
    points = @points
    end
    points
    end

    end



    ubit = Company.new("Ubit", "Tokyo, Japan", "http://ubit.com")
    ubit.description =<<EOF
    Ubit is a Japanese company focusing on mobile phone services and
    content aggregation both in Japan and abroad.
    EOF

    developer = Job.new("Software Developer")
    developer.description =<<EOF
    Become knowledgeable in the inner workings of our
    product platform and work as a team with other developers to implement
    new features and improve our current capabilities. Ideally, you are
    willing to work under dynamic conditions and communicate well with
    others.
    EOF


    loose_find = lambda do |data, reg_match|
    data.find { |v| v =~ match }
    end

    reqs = Array.new
    reqs<< Requirement.new(25) do |ja|
    ja.spoken_languages.include?("English")
    end

    reqs<< Requirement.new(25) do |ja|
    ja.spoken_languages.include?("Japanese")
    end

    reqs<< Requirement.new(5) do |ja|
    sub = ["English", "Japanese"]
    (ja.spoken_languages - sub).size > 0
    end

    reqs<< Requirement.new(50) do |ja|
    ja.computer_languages_skills.include?("Ruby")
    end

    reqs<< Requirement.new(25) do |ja|
    ja.computer_languages_skills.include?("Databases")
    end

    reqs<< Requirement.new(10) do |ja|
    ja.computer_languages_skills.include?("Mobile Technologies")
    end

    reqs<< Requirement.new(5) do |ja|
    ja.computer_languages_skills.include?("*NIX")
    end

    reqs<< Requirement.new(5) do |ja|
    (ja.computer_languages_skills - ["Ruby", "Database"]).size > 0
    end

    reqs<< Requirement.new(25) do |ja|
    ja.location =~ /Japan/i
    end

    developer.requirements = reqs
    developer.threshold = 125

    ubit.available_jobs<< developer

    good_match =<<EOF
    Your profile looks promising!
    If you are interested in working with us,
    please send your resume to Zev Blut at
    EOF

    nsgm =<<EOF
    Sorry, at the moment we are in need of people who meet our specific
    needs. But if you feel that you can meet them then go ahead and send
    your resume to Zev Blut at
    EOF

    ubit.announce_job_availability(good_match,nsgm)
    Zev Blut, Mar 7, 2005
    #1
    1. Advertising

  2. Zev Blut

    Tim Ferrell Guest

    Now that is just too cool :)

    Cheers,
    Tim

    Zev Blut wrote:
    > #!/usr/bin/env ruby
    >
    > # Warning this is a job announcement!
    > # Run it/Read it if you are interested.
    > # Lack of comments and robust input handling are intentional.
    >
    > class Company
    > attr_accessor :name, :location, :web_site, :description
    > attr_accessor :available_jobs
    >
    > def initialize(name = nil, location = nil, web_site = nil)
    > self.name = name
    > self.location = location
    > self.web_site = web_site
    > self.available_jobs = Array.new
    > end
    >
    > def ask_for_interview?(job_applicant)
    > available_jobs.each do |ajob|
    > return true if ajob.meets_requirements?(job_applicant)
    > end
    > false
    > end
    >
    > def describe
    > puts "Company : #{name}"
    > puts "Location : #{location}"
    > puts "Web site : #{web_site}"
    > puts "","Brief description :"
    > puts description, ""
    > end
    >
    > def announce_job_availability(good_match, not_so_good_match)
    > return if available_jobs.empty?
    > describe
    > puts "Available jobs:"
    > available_jobs.each_with_index do |job, idx|
    > puts "", "#{idx + 1} ) #{job.name}", job.description, ""
    > end
    >
    > job_applicant = ask_for_job_applicant_information
    > return if job_applicant.nil?
    >
    > if ask_for_interview?( job_applicant )
    > puts good_match
    > else
    > puts not_so_good_match
    > end
    > end
    >
    > def ask_for_job_applicant_information
    > job_applicant = nil
    > puts "Would you like to apply for a job? Y/N"
    > res = gets.chomp
    > if res =~ /Y/i
    > msg = "Great! Please follow the prompts to input your profile"
    > msg<< " to see if there if a job matches."
    > puts msg, ""
    > job_applicant = JobApplicant.new_from_interactive_shell
    > else
    > puts "Well thanks for reading/running the program! Good Bye!"
    > end
    > job_applicant
    > end
    >
    > end
    >
    > class Job
    > attr_accessor :name, :description, :requirements, :threshold
    > def initialize(name = nil, description = nil,
    > threshold = 100, requirements = [] )
    > self.name = name
    > self.description = description
    > self.requirements = requirements
    > self.threshold = threshold
    > end
    >
    > def meets_requirements?(job_applicant)
    > points = 0
    > requirements.each do |req|
    > points += req.check_requirement(job_applicant)
    > end
    > points >= threshold
    > end
    >
    > end
    >
    > class JobApplicant
    > attr_accessor :name, :resume, :location
    > attr_accessor :spoken_languages, :computer_languages_skills
    > def initialize
    > self.spoken_languages = Array.new
    > self.computer_languages_skills = Array.new
    > end
    >
    > def JobApplicant.new_from_interactive_shell
    > applicant = JobApplicant.new
    > puts "What is your name?"
    > applicant.name = gets.chomp
    > puts "Where do you live? (City, Country)"
    > 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 }
    > 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 }
    > puts ""
    > applicant
    > end
    >
    > end
    >
    > class Requirement
    >
    > def initialize(points = 1, &proc)
    > @points = points
    > if proc
    > @requirement_calc = proc
    > else
    > @requirement_calc = Proc.new { |x| true }
    > end
    > end
    >
    > def check_requirement(job_applicant)
    > points = 0
    > if @requirement_calc.call(job_applicant)
    > points = @points
    > end
    > points
    > end
    >
    > end
    >
    >
    >
    > ubit = Company.new("Ubit", "Tokyo, Japan", "http://ubit.com")
    > ubit.description =<<EOF
    > Ubit is a Japanese company focusing on mobile phone services and
    > content aggregation both in Japan and abroad.
    > EOF
    >
    > developer = Job.new("Software Developer")
    > developer.description =<<EOF
    > Become knowledgeable in the inner workings of our
    > product platform and work as a team with other developers to implement
    > new features and improve our current capabilities. Ideally, you are
    > willing to work under dynamic conditions and communicate well with
    > others.
    > EOF
    >
    >
    > loose_find = lambda do |data, reg_match|
    > data.find { |v| v =~ match }
    > end
    >
    > reqs = Array.new
    > reqs<< Requirement.new(25) do |ja|
    > ja.spoken_languages.include?("English")
    > end
    >
    > reqs<< Requirement.new(25) do |ja|
    > ja.spoken_languages.include?("Japanese")
    > end
    >
    > reqs<< Requirement.new(5) do |ja|
    > sub = ["English", "Japanese"]
    > (ja.spoken_languages - sub).size > 0
    > end
    >
    > reqs<< Requirement.new(50) do |ja|
    > ja.computer_languages_skills.include?("Ruby")
    > end
    >
    > reqs<< Requirement.new(25) do |ja|
    > ja.computer_languages_skills.include?("Databases")
    > end
    >
    > reqs<< Requirement.new(10) do |ja|
    > ja.computer_languages_skills.include?("Mobile Technologies")
    > end
    >
    > reqs<< Requirement.new(5) do |ja|
    > ja.computer_languages_skills.include?("*NIX")
    > end
    >
    > reqs<< Requirement.new(5) do |ja|
    > (ja.computer_languages_skills - ["Ruby", "Database"]).size > 0
    > end
    >
    > reqs<< Requirement.new(25) do |ja|
    > ja.location =~ /Japan/i
    > end
    >
    > developer.requirements = reqs
    > developer.threshold = 125
    >
    > ubit.available_jobs<< developer
    >
    > good_match =<<EOF
    > Your profile looks promising!
    > If you are interested in working with us,
    > please send your resume to Zev Blut at
    > EOF
    >
    > nsgm =<<EOF
    > Sorry, at the moment we are in need of people who meet our specific
    > needs. But if you feel that you can meet them then go ahead and send
    > your resume to Zev Blut at
    > EOF
    >
    > ubit.announce_job_availability(good_match,nsgm)
    >
    Tim Ferrell, Mar 7, 2005
    #2
    1. Advertising

  3. Zev Blut

    Tom Willis Guest

    On Tue, 8 Mar 2005 02:01:39 +0900, Tim Ferrell <> wrote:
    > Now that is just too cool :)
    >
    > Cheers,
    > Tim
    >
    > Zev Blut wrote:
    > > #!/usr/bin/env ruby
    > >
    > > # Warning this is a job announcement!
    > > # Run it/Read it if you are interested.
    > > # Lack of comments and robust input handling are intentional.
    > >
    > > class Company
    > > attr_accessor :name, :location, :web_site, :description
    > > attr_accessor :available_jobs
    > >
    > > def initialize(name = nil, location = nil, web_site = nil)
    > > self.name = name
    > > self.location = location
    > > self.web_site = web_site
    > > self.available_jobs = Array.new
    > > end
    > >
    > > def ask_for_interview?(job_applicant)
    > > available_jobs.each do |ajob|
    > > return true if ajob.meets_requirements?(job_applicant)
    > > end
    > > false
    > > end
    > >
    > > def describe
    > > puts "Company : #{name}"
    > > puts "Location : #{location}"
    > > puts "Web site : #{web_site}"
    > > puts "","Brief description :"
    > > puts description, ""
    > > end
    > >
    > > def announce_job_availability(good_match, not_so_good_match)
    > > return if available_jobs.empty?
    > > describe
    > > puts "Available jobs:"
    > > available_jobs.each_with_index do |job, idx|
    > > puts "", "#{idx + 1} ) #{job.name}", job.description, ""
    > > end
    > >
    > > job_applicant = ask_for_job_applicant_information
    > > return if job_applicant.nil?
    > >
    > > if ask_for_interview?( job_applicant )
    > > puts good_match
    > > else
    > > puts not_so_good_match
    > > end
    > > end
    > >
    > > def ask_for_job_applicant_information
    > > job_applicant = nil
    > > puts "Would you like to apply for a job? Y/N"
    > > res = gets.chomp
    > > if res =~ /Y/i
    > > msg = "Great! Please follow the prompts to input your profile"
    > > msg<< " to see if there if a job matches."
    > > puts msg, ""
    > > job_applicant = JobApplicant.new_from_interactive_shell
    > > else
    > > puts "Well thanks for reading/running the program! Good Bye!"
    > > end
    > > job_applicant
    > > end
    > >
    > > end
    > >
    > > class Job
    > > attr_accessor :name, :description, :requirements, :threshold
    > > def initialize(name = nil, description = nil,
    > > threshold = 100, requirements = [] )
    > > self.name = name
    > > self.description = description
    > > self.requirements = requirements
    > > self.threshold = threshold
    > > end
    > >
    > > def meets_requirements?(job_applicant)
    > > points = 0
    > > requirements.each do |req|
    > > points += req.check_requirement(job_applicant)
    > > end
    > > points >= threshold
    > > end
    > >
    > > end
    > >
    > > class JobApplicant
    > > attr_accessor :name, :resume, :location
    > > attr_accessor :spoken_languages, :computer_languages_skills
    > > def initialize
    > > self.spoken_languages = Array.new
    > > self.computer_languages_skills = Array.new
    > > end
    > >
    > > def JobApplicant.new_from_interactive_shell
    > > applicant = JobApplicant.new
    > > puts "What is your name?"
    > > applicant.name = gets.chomp
    > > puts "Where do you live? (City, Country)"
    > > 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 }
    > > 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 }
    > > puts ""
    > > applicant
    > > end
    > >
    > > end
    > >
    > > class Requirement
    > >
    > > def initialize(points = 1, &proc)
    > > @points = points
    > > if proc
    > > @requirement_calc = proc
    > > else
    > > @requirement_calc = Proc.new { |x| true }
    > > end
    > > end
    > >
    > > def check_requirement(job_applicant)
    > > points = 0
    > > if @requirement_calc.call(job_applicant)
    > > points = @points
    > > end
    > > points
    > > end
    > >
    > > end
    > >
    > >
    > >
    > > ubit = Company.new("Ubit", "Tokyo, Japan", "http://ubit.com")
    > > ubit.description =<<EOF
    > > Ubit is a Japanese company focusing on mobile phone services and
    > > content aggregation both in Japan and abroad.
    > > EOF
    > >
    > > developer = Job.new("Software Developer")
    > > developer.description =<<EOF
    > > Become knowledgeable in the inner workings of our
    > > product platform and work as a team with other developers to implement
    > > new features and improve our current capabilities. Ideally, you are
    > > willing to work under dynamic conditions and communicate well with
    > > others.
    > > EOF
    > >
    > >
    > > loose_find = lambda do |data, reg_match|
    > > data.find { |v| v =~ match }
    > > end
    > >
    > > reqs = Array.new
    > > reqs<< Requirement.new(25) do |ja|
    > > ja.spoken_languages.include?("English")
    > > end
    > >
    > > reqs<< Requirement.new(25) do |ja|
    > > ja.spoken_languages.include?("Japanese")
    > > end
    > >
    > > reqs<< Requirement.new(5) do |ja|
    > > sub = ["English", "Japanese"]
    > > (ja.spoken_languages - sub).size > 0
    > > end
    > >
    > > reqs<< Requirement.new(50) do |ja|
    > > ja.computer_languages_skills.include?("Ruby")
    > > end
    > >
    > > reqs<< Requirement.new(25) do |ja|
    > > ja.computer_languages_skills.include?("Databases")
    > > end
    > >
    > > reqs<< Requirement.new(10) do |ja|
    > > ja.computer_languages_skills.include?("Mobile Technologies")
    > > end
    > >
    > > reqs<< Requirement.new(5) do |ja|
    > > ja.computer_languages_skills.include?("*NIX")
    > > end
    > >
    > > reqs<< Requirement.new(5) do |ja|
    > > (ja.computer_languages_skills - ["Ruby", "Database"]).size > 0
    > > end
    > >
    > > reqs<< Requirement.new(25) do |ja|
    > > ja.location =~ /Japan/i
    > > end
    > >
    > > developer.requirements = reqs
    > > developer.threshold = 125
    > >
    > > ubit.available_jobs<< developer
    > >
    > > good_match =<<EOF
    > > Your profile looks promising!
    > > If you are interested in working with us,
    > > please send your resume to Zev Blut at
    > > EOF
    > >
    > > nsgm =<<EOF
    > > Sorry, at the moment we are in need of people who meet our specific
    > > needs. But if you feel that you can meet them then go ahead and send
    > > your resume to Zev Blut at
    > > EOF
    > >
    > > ubit.announce_job_availability(good_match,nsgm)
    > >

    >
    >


    That's what I was thinking.




    --
    Thomas G. Willis
    http://paperbackmusic.net
    Tom Willis, Mar 7, 2005
    #3
  4. Zev Blut

    Ben Giddings Guest

    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. :) )
    Ben Giddings, Mar 7, 2005
    #4
  5. Zev Blut

    Ben Giddings Guest

    Oops, I missed a bug I introduced:

    --- tokyo_job.rb 2005-03-07 13:22:38.470951276 -0500
    +++ tokyo_job.rb.fixed 2005-03-07 13:22:48.733296933 -0500
    @@ -176,7 +176,7 @@

    reqs<< Requirement.new(25) do |ja|
    ja.computer_languages_skills.grep(/database/).size > 0 or
    - ja.computer_languages_skills.grep(/\bdb\b/).size > 0
    + ja.computer_languages_skills.grep(/\bdb\b/).size > 0 or
    ja.computer_languages_skills.grep(/sql/).size > 0
    end
    Ben Giddings, Mar 7, 2005
    #5
  6. Zev Blut

    Eric Hodel Guest

    --Apple-Mail-70-930182910
    Content-Transfer-Encoding: 7bit
    Content-Type: text/plain; charset=US-ASCII; format=flowed

    On 07 Mar 2005, at 06:53, Zev Blut wrote:

    > #!/usr/bin/env ruby
    >
    > # Warning this is a job announcement!
    > # Run it/Read it if you are interested.
    > # Lack of comments and robust input handling are intentional.
    >
    > class Company
    > attr_accessor :name, :location, :web_site, :description
    > attr_accessor :available_jobs
    >
    > def initialize(name = nil, location = nil, web_site = nil)
    > self.name = name
    > self.location = location
    > self.web_site = web_site
    > self.available_jobs = Array.new
    > end
    >
    > def ask_for_interview?(job_applicant)
    > available_jobs.each do |ajob|
    > return true if ajob.meets_requirements?(job_applicant)
    > end
    > false
    > end
    >
    > def describe
    > puts "Company : #{name}"
    > puts "Location : #{location}"
    > puts "Web site : #{web_site}"
    > puts "","Brief description :"
    > puts description, ""
    > end


    I like this better, much cleaner than puts with ',', which I don't see
    very often. Also, you could pass this array around everywhere, then
    join the whole thing up at the end for printing (so you could, say,
    HTML format it or something).

    def describe
    desc = []
    desc << "Company : #{name}"
    desc << "Location : #{location}"
    desc << "Web site : #{web_site}"
    desc << "" << "Brief description :" << description << ""
    puts desc.join('\n')
    end

    > def announce_job_availability(good_match, not_so_good_match)
    > return if available_jobs.empty?
    > describe
    > puts "Available jobs:"
    > available_jobs.each_with_index do |job, idx|
    > puts "", "#{idx + 1} ) #{job.name}", job.description, ""
    > end
    >
    > job_applicant = ask_for_job_applicant_information
    > return if job_applicant.nil?
    >
    > if ask_for_interview?( job_applicant )
    > puts good_match
    > else
    > puts not_so_good_match
    > end
    > end
    >
    > def ask_for_job_applicant_information
    > job_applicant = nil
    > puts "Would you like to apply for a job? Y/N"
    > res = gets.chomp
    > if res =~ /Y/i
    > msg = "Great! Please follow the prompts to input your profile"
    > msg<< " to see if there if a job matches."
    > puts msg, ""
    > job_applicant = JobApplicant.new_from_interactive_shell
    > else
    > puts "Well thanks for reading/running the program! Good Bye!"
    > end
    > job_applicant
    > end
    >
    > end
    >
    > class Job
    > attr_accessor :name, :description, :requirements, :threshold
    > def initialize(name = nil, description = nil,
    > threshold = 100, requirements = [] )
    > self.name = name
    > self.description = description
    > self.requirements = requirements
    > self.threshold = threshold
    > end
    >
    > def meets_requirements?(job_applicant)
    > points = 0
    > requirements.each do |req|
    > points += req.check_requirement(job_applicant)
    > end
    > points >= threshold
    > end
    >
    > end
    >
    > class JobApplicant
    > attr_accessor :name, :resume, :location
    > attr_accessor :spoken_languages, :computer_languages_skills
    > def initialize
    > self.spoken_languages = Array.new
    > self.computer_languages_skills = Array.new
    > end
    >
    > def JobApplicant.new_from_interactive_shell
    > applicant = JobApplicant.new
    > puts "What is your name?"
    > applicant.name = gets.chomp
    > puts "Where do you live? (City, Country)"
    > 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 }
    > 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 }
    > puts ""
    > applicant
    > end
    >
    > end
    >
    > class Requirement
    >
    > def initialize(points = 1, &proc)
    > @points = points
    > if proc
    > @requirement_calc = proc
    > else
    > @requirement_calc = Proc.new { |x| true }
    > end
    > end
    >
    > def check_requirement(job_applicant)
    > points = 0
    > if @requirement_calc.call(job_applicant)
    > points = @points
    > end
    > points
    > end


    def check_requirement(applicant)
    if @requirement_calc.call applicant then
    return @points
    else
    return 0
    end
    end

    Is clearer. If you like minimal-number-of-lines, then:

    def check_requirement(applicant)
    @requirement_calc.call(applicant) ? @points : 0
    end

    > end
    >
    > loose_find = lambda do |data, reg_match|
    > data.find { |v| v =~ match }
    > end


    loose_find = lambda do |data, reg_match|
    data.find { |v| v =~ reg_match }
    end

    > reqs = Array.new
    > reqs<< Requirement.new(25) do |ja|
    > ja.spoken_languages.include?("English")
    > end


    Too wordy.

    class Requirements < Array
    def add(points, &block)
    req = Requirement.new(25, &block)
    super(req)
    end
    end

    reqs = Requirements.new

    reqs.add 25 { |ja| ja.spoken_languages.include? 'English' }
    reqs.add 25 { |ja| ja.spoken_languages.include? 'Japanese' }
    [...]

    > developer.requirements = reqs
    > developer.threshold = 125
    >
    > ubit.available_jobs<< developer
    >
    > good_match =<<EOF
    > Your profile looks promising!
    > If you are interested in working with us,
    > please send your resume to Zev Blut at
    > EOF
    >
    > nsgm =<<EOF
    > Sorry, at the moment we are in need of people who meet our specific
    > needs. But if you feel that you can meet them then go ahead and send
    > your resume to Zev Blut at
    > EOF
    >
    > ubit.announce_job_availability(good_match,nsgm)
    >


    --
    Eric Hodel - - http://segment7.net
    FEC2 57F1 D465 EB15 5D6E 7C11 332A 551C 796C 9F04

    --Apple-Mail-70-930182910
    content-type: application/pgp-signature; x-mac-type=70674453;
    name=PGP.sig
    content-description: This is a digitally signed message part
    content-disposition: inline; filename=PGP.sig
    content-transfer-encoding: 7bit

    -----BEGIN PGP SIGNATURE-----
    Version: GnuPG v1.2.4 (Darwin)

    iD8DBQFCLNMeMypVHHlsnwQRAnKhAJ9SmEQDJc40QT6cfhfJEqqKAb7bgwCeKCF8
    X8Z46HqNn2Hl6JLbp8sWt30=
    =qQMT
    -----END PGP SIGNATURE-----

    --Apple-Mail-70-930182910--
    Eric Hodel, Mar 7, 2005
    #6
  7. Zev Blut

    Zev Blut Guest

    Hi all,

    Thanks for all the comments and improvements to the coded request for
    Ruby developers! It was certainly more fun than writing a formal job
    posting. Hopefully, I will get a few resumes in my mailbox...

    Best,
    Zev
    Zev Blut, Mar 8, 2005
    #7
  8. Zev Blut

    John Carter Guest

    Whats wrong with just...

    def describe
    puts "\
    Company : #{name}
    Location : #{location}
    Web site : #{web_site}

    Brief description :
    #{description}

    "
    end


    On Tue, 8 Mar 2005, Eric Hodel wrote:

    > On 07 Mar 2005, at 06:53, Zev Blut wrote:
    >
    >> def describe
    >> puts "Company : #{name}"
    >> puts "Location : #{location}"
    >> puts "Web site : #{web_site}"
    >> puts "","Brief description :"
    >> puts description, ""
    >> end

    >
    > I like this better, much cleaner than puts with ',', which I don't see very
    > often. Also, you could pass this array around everywhere, then join the
    > whole thing up at the end for printing (so you could, say, HTML format it or
    > something).
    >
    > def describe
    > desc = []
    > desc << "Company : #{name}"
    > desc << "Location : #{location}"
    > desc << "Web site : #{web_site}"
    > desc << "" << "Brief description :" << description << ""
    > puts desc.join('\n')
    > end




    John Carter Phone : (64)(3) 358 6639
    Tait Electronics Fax : (64)(3) 359 4632
    PO Box 1645 Christchurch Email :
    New Zealand

    Refactorers do it a little better every time.
    John Carter, Mar 10, 2005
    #8
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Carl Friedrich Bolz

    Next PyPy Sprint: Tokyo 23/4 - 29/4

    Carl Friedrich Bolz, Mar 27, 2006, in forum: Python
    Replies:
    0
    Views:
    285
    Carl Friedrich Bolz
    Mar 27, 2006
  2. cwmtrader
    Replies:
    0
    Views:
    311
    cwmtrader
    Feb 8, 2008
  3. Replies:
    0
    Views:
    283
  4. Guy
    Replies:
    0
    Views:
    102
  5. Replies:
    0
    Views:
    84
Loading...

Share This Page