class SynapsePayRest::Question

Represents a question that is triggered when a document is returned with status MFA|PENDING.

@deprecated

Attributes

answers[R]

@!attribute [r] question

@return [String] the text of the question

@!attribute [r] answers

@return [Hash{Integer=>String}] the answer choice numbers and text

@!attribute [r] id

@return [Integer] the number of the question in the question_set

@!attribute [r] choice

@return [String,void] the chosen answer (starts out nil)
choice[R]

@!attribute [r] question

@return [String] the text of the question

@!attribute [r] answers

@return [Hash{Integer=>String}] the answer choice numbers and text

@!attribute [r] id

@return [Integer] the number of the question in the question_set

@!attribute [r] choice

@return [String,void] the chosen answer (starts out nil)
id[R]

@!attribute [r] question

@return [String] the text of the question

@!attribute [r] answers

@return [Hash{Integer=>String}] the answer choice numbers and text

@!attribute [r] id

@return [Integer] the number of the question in the question_set

@!attribute [r] choice

@return [String,void] the chosen answer (starts out nil)
question[R]

@!attribute [r] question

@return [String] the text of the question

@!attribute [r] answers

@return [Hash{Integer=>String}] the answer choice numbers and text

@!attribute [r] id

@return [Integer] the number of the question in the question_set

@!attribute [r] choice

@return [String,void] the chosen answer (starts out nil)

Public Class Methods

new(id:, question:, answers:) click to toggle source

@note This is initialized automatically by SynapsePayRest::VirtualDocument.

# File lib/synapse_pay_rest/models/user/question.rb, line 18
def initialize(id:, question:, answers:)
  @id       = id
  @question = question
  @answers  = answers
  @choice   = nil
end

Public Instance Methods

choice=(answer_number) click to toggle source

Selects the user's answer choice for this question. This does not submit it to the API - you must call VirtualDocument#submit once all questions have been answered.

@param answer_number [Integer] the user's chosen answer

@return [Integer] the answer chosen

# File lib/synapse_pay_rest/models/user/question.rb, line 32
def choice=(answer_number)
  raise ArgumentError, 'answer_number must be an Integer' unless answer_number.is_a?(Integer)
  unless answers.keys.include? answer_number
    raise ArgumentError, "answer given must be in #{answers.keys}"
  end

  @choice = answer_number
end
to_hash() click to toggle source

Converts the question/answer to a hash for use in JSON. @note You should not need to call this directly.

# File lib/synapse_pay_rest/models/user/question.rb, line 43
def to_hash
  {'question_id' => id, 'answer_id' => choice}
end