Skip to content

Instantly share code, notes, and snippets.

@twinge
Created June 7, 2011 00:11
Show Gist options
  • Save twinge/1011406 to your computer and use it in GitHub Desktop.
Save twinge/1011406 to your computer and use it in GitHub Desktop.
@peeps = @people.collect {|z| z.to_hash}
@answers = @answer_sheet.collect { |ax| @question_sheet.questions.collect {|x| x.display_response(ax)}}
@questions = @question_sheet.questions.collect {|y| y.attributes.slice(:kind, :label, :style, :required, :content)}
0.upto(@peeps.length-1) do |p|
hash = Hash.new
hash = {"person" => @peeps[p]}
qa = []
0.upto(@questions.length-1) do |q|
qa[q] = {"q" => @questions[q], "a" => @answers[p][q] }
end
hash[:form] = qa
dh.push hash
end
can be written as
@answers = @answer_sheet.collect { |ax| @question_sheet.questions.collect {|x| x.display_response(ax)}}
@questions = @question_sheet.questions.collect {|y| y.attributes.slice(:kind, :label, :style, :required, :content)}
dh = @people.collect {|person| {person: person, form: @questions.collect {|q| {q: q, a: @answers[person][q]}}}}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment