From: William James Date: 2005-11-05T06:27:11+09:00 Subject: Re: What's your Ruby Number? (self.to_i) Hal Fulton wrote: > I offer this in the spirit of the old "purity test" and the > "nerdity test" that was derived therefrom. > > Don't take it *too* seriously. All point weights are strictly > my opinion and are subject to change. > > > Version 1.0 follows... cut, paste, run. Or just cut and run. > > > Cheers, > Hal > > > > def add(n) > @sum += n > puts "#{n} points (#{@sum} total)" > puts > end > > def yorn > print "(y/n): " > ch = gets.chomp > ch=='y' ? 1 : 0 > end > > @sum = 0 > > puts > puts "First, three background geek questions:" > puts > > puts "How many degrees in computer science do you have?" > deg = gets.to_i > add(deg*4) > > puts "In what year did your write your FIRST program in any language?" > fp = gets.to_i > div4 = ((Time.now.year - fp)/4.0).ceil > add(div4*1) > > puts "How many years have you worked in a software-related job?" > yrs = gets.to_i > div4 = (yrs/4.0).ceil > add(div4*1) > > puts "\n----------------------" > puts "And now the Ruby stuff:" > puts > > puts "In what year did you start using Ruby? (4 digits)" > yr = gets.to_i > partial = Time.now.year - yr > add(partial*2) > > puts "In what year did you start reading the list or newsgroup? (4 digits)" > yr = gets.to_i > partial = Time.now.year - yr > add(partial*4) > > puts "How many (non-vaporware) entries do you have in RAA and/or Rubyforge?" > raa = gets.to_i > add(raa*1) > > puts "How many Ruby conferences have you assisted in organizing? (US or other)" > conf = gets.to_i > add(conf*6) > > puts "Have you assisted in forming a local user's group?" > local = yorn > add(local*2) > > puts "At how many Ruby conferences have you made presentations?" > conf = gets.to_i > add(conf*6) > > puts "How many Ruby conferences have you attended?" > conf = gets.to_i > add(conf*4) > > puts "Now, some book questions." > puts "Translations and newer editions count separately..." > puts > > puts "How many Ruby books list you as an author?" > book = gets.to_i > add(book*6) > > puts "How many (other) Ruby books have you contributed to?" > book = gets.to_i > add(book*4) > > puts "How many (other) Ruby books mention your name?" > book = gets.to_i > add(book*2) > > puts "How many unique Ruby books do you own?" > books = gets.to_i > add(books*1) > > puts "Do you own a domain name (with content) including the word 'ruby'?" > dom = yorn > add(dom*2) > > puts "Approximately how many packages of yours are now in the core or stdlib?" > core = gets.to_i > add(core*1) > > puts "Is your name Yukihiro Matsumoto?" > matz = yorn > add(matz*10) > > puts "Is your name Dave Thomas or Guy Decoux?" > dave = yorn > add(dave*6) > > puts "Is your name: Nobu Nokada, Shugo Maeda, or Minero Aoki?" > nobu = yorn > add(nobu*4) > > puts "Do you know any Japanese?" > japan = yorn > add(japan*2) > > puts "Is Japanese your first language?" > japan = yorn > add(japan*3) > > puts "Have you ever written Ruby for pay?" > pay = yorn > add(pay*10) > > puts "Estimate your total lines of Ruby code written." > loc = (gets.to_i/5000.0).ceil > add(loc*1) > > puts "How many Ruby presentations have you made (outside RubyConf)?" > nconf = gets.to_i > add(nconf*4) > > puts "How many of your Ruby packages have been downloaded >500 times?" > over500 = gets.to_i > add(over500*3) > > puts "Ever had an RCR accepted?" > rcr = yorn > add(rcr*5) > > > puts "That's all... your Ruby Geek status is measured at #@sum." > puts "Have a great day, and keep coding!" > puts I have a feeling that Robert will be unhappy until this contains a couple of injects. puts [ [ "\nFirst, three background geek questions:" ], [ "\nHow many degrees in computer science do you have?", :i, 4 ], [ "In what year did your write your FIRST program in any language?", :y, [4] ], [ "How many years have you worked in a software-related job?", :i, [4] ], [ "\n----------------------" ], [ "And now the Ruby stuff:" ], [ "\nIn what year did you start using Ruby?", :y, 2 ], [ "In what year did you start reading the list or newsgroup?", :y, 4 ], [ "How many (non-vaporware) entries do you have in RAA and/or Rubyforge?", :i ], [ "How many Ruby conferences have you assisted in organizing? (US or other)", :i, 6 ], [ "Have you assisted in forming a local user's group?", :YN, 2 ], [ "At how many Ruby conferences have you made presentations?", :i, 6 ], [ "How many Ruby conferences have you attended?", :i, 4 ], [ "Now, some book questions." ], [ "Translations and newer editions count separately..." ], [ "\nHow many Ruby books list you as an author?", :i, 6 ], [ "How many (other) Ruby books have you contributed to?", :i, 4 ], [ "How many (other) Ruby books mention your name?", :i, 2 ], [ "How many unique Ruby books do you own?", :i ], [ "Do you own a domain name (with content) including the word 'ruby'?", :YN, 2 ], [ "Approximately how many packages of yours are now in the core or stdlib?", :i ], [ "Is your name Yukihiro Matsumoto?", :YN, 10 ], [ "Is your name Dave Thomas or Guy Decoux?", :YN, 6 ], [ "Is your name: Nobu Nokada, Shugo Maeda, or Minero Aoki?", :YN, 4 ], [ "Do you know any Japanese?", :YN, 2 ], [ "Is Japanese your first language?", :YN, 3 ], [ "Have you ever written Ruby for pay?", :YN, 10 ], [ "Estimate your total lines of Ruby code written.", :i, [5_000] ], [ "How many Ruby presentations have you made (outside RubyConf)?", :i, 4 ], [ "How many of your Ruby packages have been downloaded >500 times?", :i, 3 ], [ "Ever had an RCR accepted?", :YN, 5 ], [ "That's all... your Ruby Geek status is measured at" ] ].inject(0){ |sum,question| puts question.shift points = question.inject(0){ |num,x| case when :i == x gets.to_i when :YN == x (gets =~ /^y/i) ? 1 : 0 when :y == x num = gets.to_i num += (num<20) ? 2000 : 1900 if num < 100 Time.now.year - num when x.respond_to?(:pop) ( num / x.first.to_f ).ceil when x.respond_to?(:/) num * x else raise "\n\n\aBad item: #{ x.inspect }\n\n" end } puts " #{points} points (#{sum+points} total)\n\n" if question.size > 1 sum + points }