Class: ScormEngine::Models::CourseImport

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#courseObject

TODO: Not sure we want this to be settable. Will depend on how we go about creating/updating records. For now it makes it easier to create instances from API options hash.



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

def course
  @course
end

#idObject

TODO: Not sure we want this to be settable. Will depend on how we go about creating/updating records. For now it makes it easier to create instances from API options hash.



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

def id
  @id
end

#options=(value) ⇒ Object

Sets the attribute options

Parameters:

  • value

    the value to set the attribute options to.



4
5
6
# File 'lib/scorm_engine/models/course_import.rb', line 4

def options=(value)
  @options = value
end

#parser_warningsObject

TODO: Not sure we want this to be settable. Will depend on how we go about creating/updating records. For now it makes it easier to create instances from API options hash.



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

def parser_warnings
  @parser_warnings
end

#statusObject

TODO: Not sure we want this to be settable. Will depend on how we go about creating/updating records. For now it makes it easier to create instances from API options hash.



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

def status
  @status
end

Class Method Details

.new_from_api(options = {}) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/scorm_engine/models/course_import.rb', line 12

def self.new_from_api(options = {})
  this = new
  this.options = options.dup

  if options.key?("importResult")
    this.id = options["result"]
    this.status = options.fetch("importResult", {})["status"]
    this.parser_warnings = options.fetch("importResult", {})["parserWarnings"]
  else
    this.id = options["jobId"]
    this.status = options["status"]
    this.course = Course.new_from_api(options["course"]) if options.key?("course") # unavailable in error states
  end

  this
end

Instance Method Details

#complete?Boolean

Returns:

  • (Boolean)


37
38
39
# File 'lib/scorm_engine/models/course_import.rb', line 37

def complete?
  status == "COMPLETE"
end

#error?Boolean

Returns:

  • (Boolean)


33
34
35
# File 'lib/scorm_engine/models/course_import.rb', line 33

def error?
  status == "ERROR"
end

#running?Boolean

Returns:

  • (Boolean)


29
30
31
# File 'lib/scorm_engine/models/course_import.rb', line 29

def running?
  status == "RUNNING"
end