From: Nick Sieger Date: 2005-10-26T01:43:31+09:00 Subject: Re: What's your Ruby Number? (self.to_i) ------=_Part_19628_9568256.1130258606610 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline On 10/25/05, Robert Klemme wrote: > > > > > Maybe you could try the test again, and increase your LOC estimate by > > 5000 or so... > > LOL No way: I forgot the other answers... :-)) > > You can try this mod which saves your answers (ruby vets feel free to compact this even more): =3D=3D=3D start require 'yaml' @sum =3D 0 if File.exist?('ruby_number.yml') File.open('ruby_number.yml') do |f| @answers =3D YAML::load(f) end end @answers ||=3D {} def question(name) @current =3D name yield end def answer puts "(Previous answer: #{@answers[@current]})" if @answers[@current] reply =3D gets.chomp @answers[@current] =3D reply if reply.length > 0 @answers[@current] end def add(n) @sum +=3D n @answers[:total] =3D @sum puts "#{n} points (#{@sum} total)" puts end def yorn print "(y/n): " ch =3D answer ch=3D=3D'y' ? 1 : 0 end puts puts "First, three background geek questions:" puts question :compsci_degrees do puts "How many degrees in computer science do you have?" deg =3D answer.to_i add(deg*4) end question :first_program_year do puts "In what year did your write your FIRST program in any language?" fp =3D answer.to_i div4 =3D ((Time.now.year - fp)/4.0).ceil add(div4*1) end question :software_job_years do puts "How many years have you worked in a software-related job?" yrs =3D answer.to_i div4 =3D (yrs/4.0).ceil add(div4*1) end puts "\n----------------------" puts "And now the Ruby stuff:" puts question :started_with_ruby_year do puts "In what year did you start using Ruby? (4 digits)" yr =3D answer.to_i partial =3D Time.now.year - yr add(partial*2) end question :started_reading_newsgroup do puts "In what year did you start reading the list or newsgroup? (4 digits)" yr =3D answer.to_i partial =3D Time.now.year - yr add(partial*4) end question :raa_rubyforge_entries do puts "How many (non-vaporware) entries do you have in RAA and/or Rubyforge\?" raa =3D answer.to_i add(raa*1) end question :rubyconf_organize do puts "How many Ruby conferences have you assisted in organizing? (US or other)" conf =3D answer.to_i add(conf*6) end question :local_user_group do puts "Have you assisted in forming a local user's group\?" local =3D yorn add(local*2) end question :rubyconf_presentations do puts "At how many Ruby conferences have you made presentations\?" conf =3D answer.to_i add(conf*6) end question :rubyconf_attended do puts "How many Ruby conferences have you attended\?" conf =3D answer.to_i add(conf*4) end puts "Now, some book questions." puts "Translations and newer editions count separately..." puts question :ruby_books_authored do puts "How many Ruby books list you as an author\?" book =3D answer.to_i add(book*6) end question :ruby_books_contributed_to do puts "How many (other) Ruby books have you contributed to\?" book =3D answer.to_i add(book*4) end question :ruby_books_mention do puts "How many (other) Ruby books mention your name\?" book =3D answer.to_i add(book*2) end question :ruby_books_owned do puts "How many unique Ruby books do you own\?" books =3D answer.to_i add(books*1) end question :ruby_domain_name do puts "Do you own a domain name (with content) including the word 'ruby'\?" dom =3D yorn add(dom*2) end question :packages_in_core_or_stdlib do puts "Approximately how many packages of yours are now in the core or stdlib\?" core =3D answer.to_i add(core*1) end question :matz do puts "Is your name Yukihiro Matsumoto\?" matz =3D yorn add(matz*10) end question :dave_or_guy do puts "Is your name Dave Thomas or Guy Decoux\?" dave =3D yorn add(dave*6) end question :nobu_shugo_or_minero do puts "Is your name: Nobu Nokada, Shugo Maeda, or Minero Aoki\?" nobu =3D yorn add(nobu*4) end question :japanese do puts "Do you know any Japanese\?" japan =3D yorn add(japan*2) end question :japanese_first_language do puts "Is Japanese your first language\?" japan =3D yorn add(japan*3) end question :ruby_for_pay do puts "Have you ever written Ruby for pay\?" pay =3D yorn add(pay*10) end question :ruby_loc_written do puts "Estimate your total lines of Ruby code written." loc =3D (answer.to_i/5000.0).ceil add(loc*1) end question :ruby_presentations do puts "How many Ruby presentations have you made (outside RubyConf)\?" nconf =3D answer.to_i add(nconf*4) end question :ruby_packages_downloaded do puts "How many of your Ruby packages have been downloaded >500 times\?" over500 =3D answer.to_i add(over500*3) end question :rcr_accepted do puts "Ever had an RCR accepted\?" rcr =3D yorn add(rcr*5) end puts "That's all... your Ruby Geek status is measured at #@sum." puts "Have a great day, and keep coding!" puts File.open('ruby_number.yml', 'wb') do |f| YAML::dump(@answers, f) end =3D=3D=3D end Oh, and I'm a ruby newb evidenced by my as yet low score of 15 :) :ruby_books_authored: "0" :started_with_ruby_year: "2005" :ruby_for_pay: n :ruby_domain_name: n :rubyconf_organize: "0" :first_program_year: "1982" :ruby_packages_downloaded: "0" :nobu_shugo_or_minero: n :total: 15 :packages_in_core_or_stdlib: "0" :ruby_books_contributed_to: "0" :ruby_loc_written: "10000" :local_user_group: n :rcr_accepted: n :japanese: n :ruby_books_mention: "0" :started_reading_newsgroup: "2005" :matz: n :rubyconf_presentations: "0" :software_job_years: "10" :ruby_books_owned: "0" :raa_rubyforge_entries: "0" :compsci_degrees: "0" :dave_or_guy: n :rubyconf_attended: "0" :ruby_presentations: "1" :japanese_first_language: n Thanks Hal for the great icebreaker! Cheers, /Nick ------=_Part_19628_9568256.1130258606610--