Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class A
- attr_reader :exp, :github, :langs, :apply, :age, :cand_index
- @@cand_hsh = Hash.new(0)
- @@cand_counter = 1
- @@cand_index_ext = 1
- def initialize(exp,github,langs,apply,age)
- @exp = exp
- @github = github
- @langs = langs
- @apply = apply
- @age = age
- @cand_index = "c00" << @@cand_index_ext.to_s
- @@cand_counter += 1
- @@cand_index_ext += 1
- process_data
- end
- def process_data
- details = {}
- details = { :exp => @exp,
- :github => @github,
- :langs => @langs,
- :apply => @apply,
- :age => @age
- }
- @@cand_hsh[@cand_index.to_sym] = details
- end
- def suitability
- cand_values = @@cand_hsh[@cand_index.to_sym].values
- cand_langs = cand_values.delete_at(2)
- requirs = [2, 500, "didnot", 25]
- #exp = 2 github = 500 apply = no age = 25
- lang_requir = "ruby"
- @cand_points = Array.new(0)
- counter = 0
- cand_values.each do |x|
- @cand_points << 1 if x >= requirs[counter]
- counter += 1
- end
- 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)
- @cand_points = @cand_points.inject(:+)
- write2file
- end
- def suitable?
- (@cand_points >= 4 and @age >= 25 and @apply and (@ruby == "YES") and (@exp >= 2 or @github >= 500)) ? "YES" : "NO"
- end
- def write2file
- langs = ""
- @langs.each {|lang| langs << lang + ". "}
- File.open("#{@cand_index}.txt", "w+") do |file|
- file.write("
- Candidate det info
- ==================
- experience = #{@exp} years;
- Ruby lang? = #{@ruby};
- github points = #{@github} points;
- applied before = #{@apply};
- age = #{@age} years;
- languages working with = #{langs}
- Candidate points - #{@cand_points} points.
- Additional points for multi-lang programming - #{@add_points}
- TOTAL = #{@cand_points + @add_points} points.
- PROPER CANDIDATE? - #{suitable?}
- =================="
- )
- end
- File.open("#{@cand_index} hash.txt", "w+") do |file|
- file.write(@@cand_hsh[@cand_index.to_sym])
- end
- end
- end
- cand001 = A.new(2,503,%W(ruby python java php),"didnot",30)
- cand002 = A.new(4,666,%W(ruby java lisp pascal),"did",16)
- cand003 = A.new(21,2013,%W(code drakon foxpro java javascript lisp),"didnot",51)
- cand003.suitability
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement