Created
November 21, 2012 04:01
-
-
Save frankyxhl/4122935 to your computer and use it in GitHub Desktop.
RubyConfChina_Feedback
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/ruby | |
# -*- coding: utf-8 -*- | |
# @date: 2012-11-20 | |
# @author: Frank_Xu franky.xhl[at]gmail.com I'm a Ruby Newbie~ | |
# 变量设定 | |
# qn = question number count | |
qn = 13 | |
# filename | |
filename = "rslt.txt" | |
# 问题设定 | |
q_selection = [ | |
# 第一次参加Ruby Conf么 | |
{ "0" => "无", "1" => "是", "2" => "否" }, | |
# 请问您来自哪里 | |
{ "0" => "无", "1" => "上海", "2" => "北京", "3" => "杭州", "4" => "广州", "5" => "温州", "6" => "重庆", "7" => "厦门", "8" => "西安", "9" => "南京", "A" => "无锡", "B" => "山东", "C" => "成都", "D" => "河北", "E" => "苏州", "F" => "大连", "G" => "南通", "H" => "天津", "I" => "深圳", "J" => "常州", "K" => "武汉", "L" => "长沙", "M" => "郑州" }, | |
# 请问您是从何处得知Ruby Conf的 | |
{ "0" => "无", "1" => "Ruby-China.org", "2" => "Facebook.com", "3" => "Weibo.com", "4" => "Github.com", "5" => "Google.com", "6" => "朋友推荐", "7" => "Iteye.com", "8" => "公司/同事", "9" => "Twitter", "A" => "松本先生", "B" => "Nanjing LUG邮件列表", "C" => "V2EX.com", "D" => "CSDN.net", "E" => "吕国宁介绍" }, | |
# 可否告知您的职务类型 | |
{ "0" => "无", "1" => "软件工程师", "2" => "项目经理/项目主管", "3" => "开发人员", "4" => "CTO/CIO/CEO", "5" => "自由职业/Ruby爱好者", "6" => "学生", "7" => "SA", "8" => "Consultunt", "9" => "前端", "A" => "Geek", "B" => "网络编辑", "C" => "某个Ruby超级群" }, | |
# 会议场地和设施您觉得怎么样 | |
{ "0" => "无", "1" => "非常好", "2" => "还不错", "3" => "勉勉强强", "4" => "让人失望" }, | |
# 主会场Day1 | |
# Matz - Ruby 2.0 | |
{ "0" => "无", "1" => "顶", "2" => "踩", "3" => "空" }, | |
# Jesse Zhang - How Cloud Foundry Did it (with Ruby) | |
{ "0" => "无", "1" => "顶", "2" => "踩", "3" => "空" }, | |
# 黄志敏 (flyerhzm) - JRuby @ OpenFeint | |
{ "0" => "无", "1" => "顶", "2" => "踩", "3" => "空" }, | |
# Fred Wu - 如何通过努力和一些小聪明,成为一个更优秀的 Ruby 程序员 | |
{ "0" => "无", "1" => "顶", "2" => "踩", "3" => "空" }, | |
# 陈金洲 - Ruby on Rails 创业小团队全技术栈指南 | |
{ "0" => "无", "1" => "顶", "2" => "踩", "3" => "空" }, | |
# 王益善 (Quake Wang) - Ruby Arduino Hacking | |
{ "0" => "无", "1" => "顶", "2" => "踩", "3" => "空" }, | |
# 马海波 (saberma) - 互联网创业,没有设计师,如何设计 | |
{ "0" => "无", "1" => "顶", "2" => "踩", "3" => "空" }, | |
# 王松林 - 轻量Ruby的导入与评价 | |
{ "0" => "无", "1" => "顶", "2" => "踩", "3" => "空" } | |
] | |
q_topiclist = ["第一次参加Ruby Conf么","请问您来自哪里","请问您是从何处得知Ruby Conf的","可否告知您的职务类型","会议场地和设施您觉得怎么样","Matz - Ruby 2.0","Jesse Zhang - How Cloud Foundry Did it (with Ruby)","黄志敏 (flyerhzm) - JRuby @ OpenFeint","Fred Wu - 如何通过努力和一些小聪明,成为一个更优秀的 Ruby 程序员","陈金洲 - Ruby on Rails 创业小团队全技术栈指","王益善 (Quake Wang) - Ruby Arduino Hacking","马海波 (saberma) - 互联网创业,没有设计师,如何设计","王松林 - 轻量Ruby的导入与评价"] | |
# 初始结果rslt | |
rslt = [] | |
qn.times do |x| | |
rslt[x] = {} | |
rslt[x].default = 0 | |
end | |
# 把结果变成一个数组,每个组员是一个结果选项的Hash字典 | |
file = File.open( filename ) | |
file.each do |line| | |
if line.length != qn + 1 | |
puts "#{file.lineno} 数据不合规范" | |
else | |
qn.times do |x| | |
rslt[x][line[x]] = rslt[x][line[x]] + 1 | |
end | |
end | |
end | |
file.close | |
# 拼接结果 | |
puts "RubyConfChina 2012 Day 1 Feedback" | |
print "共收到feedback",%x{wc -l #{filename}}.split.first.to_i,"份\n" | |
puts "" | |
qn.times do |x| | |
sort_array = rslt[x].sort_by {|k,v| v}.reverse | |
puts q_topiclist[x] | |
sort_array.each do |each_select| | |
if q_selection[x][each_select[0]] != "无" # 去掉弃选票 | |
print q_selection[x][each_select[0]],":",each_select[1],"票 " | |
end | |
end | |
print "\n" | |
puts "" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment