Class: GatesOfMoria::Quiz
- Inherits:
-
Object
- Object
- GatesOfMoria::Quiz
- Defined in:
- lib/gates_of_moria/quiz.rb
Instance Attribute Summary collapse
-
#motd ⇒ Object
Returns the value of attribute motd.
Instance Method Summary collapse
-
#initialize(output_buffer, input_buffer, motd = nil) ⇒ Quiz
constructor
A new instance of Quiz.
- #start ⇒ Object
Constructor Details
#initialize(output_buffer, input_buffer, motd = nil) ⇒ Quiz
Returns a new instance of Quiz.
5 6 7 8 9 10 |
# File 'lib/gates_of_moria/quiz.rb', line 5 def initialize(output_buffer, input_buffer, motd = nil) @output_buffer = output_buffer @input_buffer = input_buffer @motd = motd || File.read(File.("../data/motd.txt", __FILE__)) @questions = File.read(File.("../data/questions.json", __FILE__)) end |
Instance Attribute Details
#motd ⇒ Object
Returns the value of attribute motd.
3 4 5 |
# File 'lib/gates_of_moria/quiz.rb', line 3 def motd @motd end |
Instance Method Details
#start ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/gates_of_moria/quiz.rb', line 12 def start @output_buffer.puts @motd @repl = GatesOfMoria::REPL.new(@output_buffer, @input_buffer, @questions) player_won = @repl.start if player_won @output_buffer.puts "Congratulations! You've opened the door to the mines.\n\nGood luck on your future adventures.\n\nMight I suggest trying RubyWarrior next?\n\n https://github.com/ryanb/ruby-warrior\n" else @output_buffer.puts "\n\nYour adventures with Ruby are not over yet!\n\nMay I suggest trying the game again, or going to read up on how Ruby works at:\n\n http://www.ruby-lang.org/en/documentation/quickstart/\n" end end |