class Quiz
Attributes
list[RW]
title[RW]
Public Class Methods
new(title, &block)
click to toggle source
# File lib/quiz/quiz.rb, line 12 def initialize (title, &block) @list = Lista.new() @i = 0 @title = title @distractor = [] instance_eval &block end
Public Instance Methods
question(text,answers={})
click to toggle source
# File lib/quiz/quiz.rb, line 21 def question(text,answers={}) @text = text @right = answers[:right] if answers[:right] answers.map do |key,value| @distractor << value if key != :right end @list.add(SimpleChoice.new(:text => @text,:right => @right,:distractor => @distractor,:dif => '1')) @distractor = [] end
right()
click to toggle source
# File lib/quiz/quiz.rb, line 32 def right :right end
to_exam()
click to toggle source
# File lib/quiz/quiz.rb, line 40 def to_exam Examen.new(@list) end
wrong()
click to toggle source
# File lib/quiz/quiz.rb, line 36 def wrong @i = @i + 1 ("distractor"+@i.to_s).intern end