Class: DmtdVbmappData::AssessmentReport
- Inherits:
-
Object
- Object
- DmtdVbmappData::AssessmentReport
- Defined in:
- lib/dmtd_vbmapp_data/assessment_report.rb
Overview
Provides for the tailoring of a VB-MAPP report from the VB-MAPP Data Server.
This class retrieves the report for the given client and performs the following operations on the report data before returning the final JSON:
-
All variables are substituted
-
All conditional statements are executed and only the sections that apply are returned
The only step remaining is to format the resulting JSON into whatever output format is required (e.g. RTF, PDF, HTML, etc.).
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
The client for which the report will be generated.
-
#resolver ⇒ Object
readonly
Resolver is a block that takes a single argument, a string, which is the variable name.
Instance Method Summary collapse
-
#iep ⇒ Object
Returns the JSON for the IEP report.
-
#initialize(opts, &resolver) ⇒ AssessmentReport
constructor
Initializes the receiver with the given options:.
Constructor Details
#initialize(opts, &resolver) ⇒ AssessmentReport
Initializes the receiver with the given options:
This method does not block, simply creates an accessor and returns
29 30 31 32 |
# File 'lib/dmtd_vbmapp_data/assessment_report.rb', line 29 def initialize(opts, &resolver) @client = opts.fetch(:client) @resolver = resolver end |
Instance Attribute Details
#client ⇒ Object (readonly)
The client for which the report will be generated
21 22 23 |
# File 'lib/dmtd_vbmapp_data/assessment_report.rb', line 21 def client @client end |
#resolver ⇒ Object (readonly)
Resolver is a block that takes a single argument, a string, which is the variable name. The result should be the value to bind to that variable.
18 19 20 |
# File 'lib/dmtd_vbmapp_data/assessment_report.rb', line 18 def resolver @resolver end |
Instance Method Details
#iep ⇒ Object
This method will block on the first access to retrieve the data from the server.
The keys in the JSON hash will be symbols and not strings.
Returns the JSON for the IEP report. See /1/assessment_report/iep - GET for the full format.
The following transformations are made to the server JSON:
-
The top-level ‘response’ node is removed
-
All variables are substituted according to
resolver
-
All conditionals are evaluated
* Only paragraphs with successful conditions are retained * All Condition nodes are stripped * All Condition_Comment nodes are stripped
50 51 52 53 54 55 56 57 58 |
# File 'lib/dmtd_vbmapp_data/assessment_report.rb', line 50 def iep result = retrieve_responses_json if result.is_a?(Array) result = process_report json_array:result end result end |