class Question

Public Class Methods

new( text ) click to toggle source
# File lib/quizm.rb, line 3
def initialize( text )
  @text = text
  @answers = []
end

Public Instance Methods

add_answer(answer) click to toggle source
# File lib/quizm.rb, line 8
def add_answer(answer)
  @answers << answer
end
ask() click to toggle source
# File lib/quizm.rb, line 12
def ask
  puts ""
  puts "Question: #{@text}"
  @answers.size.times do |i|
    puts "#{i+1} - #{@answers[i].text}"
  end
  print "Enter answer: "
  answer = gets.to_i - 1
  return @answers[answer].correct
end