Advertisement
Guest User

hiring programmer

a guest
Jun 19th, 2014
316
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 2.37 KB | None | 0 0
  1. class A
  2.   attr_reader :exp, :github, :langs, :apply, :age, :cand_index
  3.   @@cand_hsh = Hash.new(0)
  4.   @@cand_counter = 1
  5.   @@cand_index_ext = 1
  6.  
  7.   def initialize(exp,github,langs,apply,age)
  8.     @exp = exp
  9.     @github = github
  10.     @langs = langs
  11.     @apply = apply
  12.     @age = age
  13.     @cand_index = "c00" << @@cand_index_ext.to_s
  14.    
  15.     @@cand_counter += 1
  16.     @@cand_index_ext += 1
  17.     process_data
  18.   end
  19.  
  20.   def process_data
  21.     details = {}
  22.     details = { :exp => @exp,
  23.                 :github => @github,
  24.                 :langs => @langs,
  25.                 :apply => @apply,
  26.                 :age => @age
  27.     }
  28.    
  29.     @@cand_hsh[@cand_index.to_sym] = details
  30.   end
  31.  
  32.   def suitability
  33.     cand_values = @@cand_hsh[@cand_index.to_sym].values
  34.     cand_langs = cand_values.delete_at(2)
  35.     requirs = [2, 500, "didnot", 25]
  36.     #exp = 2 github = 500 apply = no age = 25
  37.     lang_requir = "ruby"
  38.     @cand_points = Array.new(0)
  39.     counter = 0
  40.    
  41.     cand_values.each do |x|
  42.       @cand_points << 1 if x >= requirs[counter]
  43.       counter += 1
  44.     end
  45.    
  46.     cand_langs.include?(lang_requir) ? (@cand_points << 1 and @ruby = "YES" and @add_points = cand_langs.size * 0.5 - 0.5) : (@ruby = "NO" and @add_points = cand_langs.size * 0.5)
  47.     @cand_points = @cand_points.inject(:+)
  48.    
  49.     write2file
  50.   end
  51.    
  52.   def suitable?
  53.     (@cand_points >= 4 and @age >= 25 and @apply and (@ruby == "YES") and (@exp >= 2 or @github >= 500)) ? "YES" : "NO"
  54.   end
  55.  
  56.   def write2file
  57.     langs = ""
  58.     @langs.each {|lang| langs << lang + ". "}
  59.    
  60.     File.open("#{@cand_index}.txt", "w+") do |file|
  61.         file.write("
  62. Candidate det info
  63. ==================
  64. experience = #{@exp} years;
  65. Ruby lang? = #{@ruby};
  66. github points = #{@github} points;
  67. applied before = #{@apply};
  68. age = #{@age} years;
  69. languages working with = #{langs}
  70.  
  71. Candidate points - #{@cand_points} points.
  72. Additional points for multi-lang programming - #{@add_points}
  73. TOTAL = #{@cand_points + @add_points} points.
  74.  
  75. PROPER CANDIDATE? - #{suitable?}
  76. =================="
  77. )
  78.     end
  79.    
  80.     File.open("#{@cand_index} hash.txt", "w+") do |file|
  81.         file.write(@@cand_hsh[@cand_index.to_sym])
  82.     end
  83.   end
  84. end
  85.  
  86. cand001 = A.new(2,503,%W(ruby python java php),"didnot",30)
  87. cand002 = A.new(4,666,%W(ruby java lisp pascal),"did",16)
  88. cand003 = A.new(21,2013,%W(code drakon foxpro java javascript lisp),"didnot",51)
  89.  
  90. cand003.suitability
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement