Class: CARPS::Answers
Overview
A series of answers to questions asked by the DM.
Class Method Summary collapse
-
.parse(blob) ⇒ Object
Parse.
Instance Method Summary collapse
-
#answer(question, response) ⇒ Object
Set an answer to a question.
-
#display ⇒ Object
Display answers.
-
#emit ⇒ Object
Emit.
-
#initialize(answers_hash = {}) ⇒ Answers
constructor
The answers hash gives the initial answers.
Methods inherited from Message
#crypt, #crypt=, #delete, #from, #from=, #parse, #path=, #save, #session, #session=
Constructor Details
#initialize(answers_hash = {}) ⇒ Answers
The answers hash gives the initial answers
35 36 37 |
# File 'lib/carps/mod/answers.rb', line 35 def initialize answers_hash = {} @answers = answers_hash end |
Class Method Details
Instance Method Details
#answer(question, response) ⇒ Object
Set an answer to a question
52 53 54 |
# File 'lib/carps/mod/answers.rb', line 52 def answer question, response @answers[question] = response end |
#display ⇒ Object
Display answers
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/carps/mod/answers.rb', line 57 def display if @answers.empty? UI::highlight "#{from} did not return any answers." else UI::highlight "#{from}'s answers:" h = HighLine.new @answers.each do |que, ans| puts "" puts h.color(que, :green) ans.each_line do |ln| puts "> " + ln end end puts "" end end |
#emit ⇒ Object
Emit
47 48 49 |
# File 'lib/carps/mod/answers.rb', line 47 def emit V.answers @answers.to_yaml end |