Class: ScormEngine::Response

Inherits:
Object
  • Object
show all
Defined in:
lib/scorm_engine/response.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(raw_response:, result: nil) ⇒ Response

Returns a new instance of Response.


5
6
7
8
# File 'lib/scorm_engine/response.rb', line 5

def initialize(raw_response:, result: nil)
  @raw_response = raw_response
  @result = result
end

Instance Attribute Details

#raw_responseObject (readonly)

Returns the value of attribute raw_response.


3
4
5
# File 'lib/scorm_engine/response.rb', line 3

def raw_response
  @raw_response
end

#resultObject (readonly)

Returns the value of attribute result.


3
4
5
# File 'lib/scorm_engine/response.rb', line 3

def result
  @result
end

Instance Method Details

#messageObject


22
23
24
# File 'lib/scorm_engine/response.rb', line 22

def message
  raw_response.body["message"] if raw_response.body.is_a?(Hash)
end

#resultsObject


10
11
12
# File 'lib/scorm_engine/response.rb', line 10

def results
  result.is_a?(Enumerator) ? result : Array(result)
end

#statusObject


18
19
20
# File 'lib/scorm_engine/response.rb', line 18

def status
  raw_response.status
end

#success?Boolean

Returns:

  • (Boolean)

14
15
16
# File 'lib/scorm_engine/response.rb', line 14

def success?
  raw_response.success?
end