Class: DmtdVbmappData::ProtocolAreaQuestion

Inherits:
Object
  • Object
show all
Defined in:
lib/dmtd_vbmapp_data/protocol_area_question.rb

Overview

Provides for the retrieving of VB-MAPP Area Question on the VB-MAPP Data Server.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(opts) ⇒ ProtocolAreaQuestion

Note:

This method does not block, simply creates an accessor and returns

Creates an accessor for the VB-MAPP Area Question on the VB-MAPP Data Server

Parameters:

  • opts (Hash)

    a customizable set of options

Options Hash (opts):

  • :client (Client)

    A client instance

  • :area (String | Symbol)

    The vbmapp area of the group (‘milestones’, ‘barriers’, ‘transitions’, ‘eesa’)

  • :group (String | Symbol)

    The vbmapp area group name (i.e. ‘mand’, ‘tact’, ‘group1’, etc.)

  • :question_json (Hash)

    The vbmapp question json for the question in the format described at /1/protocol/area_question - GET REST api - Fields



65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
# File 'lib/dmtd_vbmapp_data/protocol_area_question.rb', line 65

def initialize(opts)
  @client = opts.fetch(:client)
  @area = opts.fetch(:area).to_sym
  @group = opts.fetch(:group).to_sym
  question_json = opts.fetch(:question_json)

  @definition = question_json[:definition]
  @objective = question_json[:objective]
  @example = question_json[:example]
  @materials = question_json[:materials]
  @number = question_json[:number].to_i
  @text = question_json[:text]
  @title = question_json[:title]
  @level = question_json[:level]
  @responses_json_array = question_json[:responses]

  skills = question_json[:skills]
  @skills = if skills.nil?
              []
            else
              question_json[:skills].map do |skill|
                ProtocolAreaSkill.new(question_json: skill)
              end
            end
end

Instance Attribute Details

#areaObject (readonly)

Returns the value of attribute area.



14
15
16
# File 'lib/dmtd_vbmapp_data/protocol_area_question.rb', line 14

def area
  @area
end

#clientObject (readonly)

Returns the value of attribute client.



10
11
12
# File 'lib/dmtd_vbmapp_data/protocol_area_question.rb', line 10

def client
  @client
end

#definitionObject (readonly)

Returns the value of attribute definition.



22
23
24
# File 'lib/dmtd_vbmapp_data/protocol_area_question.rb', line 22

def definition
  @definition
end

#exampleObject (readonly)

Returns the value of attribute example.



26
27
28
# File 'lib/dmtd_vbmapp_data/protocol_area_question.rb', line 26

def example
  @example
end

#groupObject (readonly)

Returns the value of attribute group.



18
19
20
# File 'lib/dmtd_vbmapp_data/protocol_area_question.rb', line 18

def group
  @group
end

#levelObject (readonly)

Returns the value of attribute level.



50
51
52
# File 'lib/dmtd_vbmapp_data/protocol_area_question.rb', line 50

def level
  @level
end

#materialsObject (readonly)

Returns the value of attribute materials.



30
31
32
# File 'lib/dmtd_vbmapp_data/protocol_area_question.rb', line 30

def materials
  @materials
end

#numberObject (readonly)

Returns the value of attribute number.



38
39
40
# File 'lib/dmtd_vbmapp_data/protocol_area_question.rb', line 38

def number
  @number
end

#objectiveObject (readonly)

Returns the value of attribute objective.



34
35
36
# File 'lib/dmtd_vbmapp_data/protocol_area_question.rb', line 34

def objective
  @objective
end

#skillsObject (readonly)

Returns the value of attribute skills.



54
55
56
# File 'lib/dmtd_vbmapp_data/protocol_area_question.rb', line 54

def skills
  @skills
end

#textObject (readonly)

Returns the value of attribute text.



42
43
44
# File 'lib/dmtd_vbmapp_data/protocol_area_question.rb', line 42

def text
  @text
end

#titleObject (readonly)

Returns the value of attribute title.



46
47
48
# File 'lib/dmtd_vbmapp_data/protocol_area_question.rb', line 46

def title
  @title
end

Instance Method Details

#responsesArray<ProtocolAreaResponse>

Note:

This method does not block.

Returns all of the VB-MAPP question’s possible responses.

Returns:



94
95
96
97
98
# File 'lib/dmtd_vbmapp_data/protocol_area_question.rb', line 94

def responses
  @responses = @responses_json_array.map { |response_json| ProtocolAreaResponse.new(area: area, response_json: response_json) } if @responses.nil?

  @responses
end