class Prct07::Quiz
Attributes
arquestions[RW]
title[RW]
Public Class Methods
new(title, &block)
click to toggle source
# File lib/prct07/quiz.rb, line 32 def initialize(title, &block) @title = title @arquestions = [] instance_eval &block end
Public Instance Methods
question(text, options = {})
click to toggle source
# File lib/prct07/quiz.rb, line 38 def question(text, options = {}) question = Question.new(text,options) @arquestions << question end
run()
click to toggle source
# File lib/prct07/quiz.rb, line 47 def run temp = title temp << "\n" @arquestions.each_with_index do |question, index| temp << "#{index+ 1})#{question}\n" end temp end
wrong(option)
click to toggle source
# File lib/prct07/quiz.rb, line 43 def wrong (option) @arquestions[-1].answer[:wrong] << option end