Class: CARPS::Question

Inherits:
Message show all
Defined in:
lib/carps/mod/question.rb

Overview

A question sent by the server, to be asked of the player.

Interacts with Answers class

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Message

#crypt, #crypt=, #delete, #from, #from=, #parse, #path=, #save, #session, #session=

Constructor Details

#initialize(question) ⇒ Question

Create a question



35
36
37
# File 'lib/carps/mod/question.rb', line 35

def initialize question
   @text = question
end

Class Method Details

.parse(blob) ⇒ Object

Parse from the void



40
41
42
43
# File 'lib/carps/mod/question.rb', line 40

def Question.parse blob
   question, blob = find K.question, blob
   [Question.new(question), blob]
end

Instance Method Details

#ask(answers) ⇒ Object

Ask the question, store the answer in the answers object



51
52
53
54
# File 'lib/carps/mod/question.rb', line 51

def ask answers
   response = UI::question @text
   answers.answer @text, response
end

#emitObject

Emit



46
47
48
# File 'lib/carps/mod/question.rb', line 46

def emit
   V.question @text 
end

#previewObject

Preview the question



57
58
59
# File 'lib/carps/mod/question.rb', line 57

def preview
   puts "Question: " + @text
end