Class: Scorm::Resource
- Inherits:
-
Object
- Object
- Scorm::Resource
- Defined in:
- lib/scorm/resource.rb
Overview
A Resource
is a representation/description of an actual resource (image, sco, pdf, etc…) in a SCORM package.
Instance Attribute Summary collapse
-
#dependencies ⇒ Object
Returns the value of attribute dependencies.
-
#files ⇒ Object
Returns the value of attribute files.
-
#href ⇒ Object
Returns the value of attribute href.
-
#id ⇒ Object
Returns the value of attribute id.
-
#metadata ⇒ Object
Returns the value of attribute metadata.
-
#scorm_type ⇒ Object
Returns the value of attribute scorm_type.
-
#type ⇒ Object
Returns the value of attribute type.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(id, type, scorm_type, href = nil, metadata = nil, files = nil, dependencies = nil) ⇒ Resource
constructor
A new instance of Resource.
Constructor Details
#initialize(id, type, scorm_type, href = nil, metadata = nil, files = nil, dependencies = nil) ⇒ Resource
Returns a new instance of Resource.
14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/scorm/resource.rb', line 14 def initialize(id, type, scorm_type, href = nil, = nil, files = nil, dependencies = nil) raise InvalidManifest, 'Missing resource id' if id.nil? raise InvalidManifest, 'Missing resource type' if type.nil? breakpoint if scorm_type.nil? raise InvalidManifest, 'Missing resource scormType' if scorm_type.nil? @id = id.to_s @type = type.to_s @scorm_type = scorm_type.to_s @href = href.to_s || '' @metadata = || Hash.new @files = files || [] @dependencies = dependencies || [] end |
Instance Attribute Details
#dependencies ⇒ Object
Returns the value of attribute dependencies.
12 13 14 |
# File 'lib/scorm/resource.rb', line 12 def dependencies @dependencies end |
#files ⇒ Object
Returns the value of attribute files.
11 12 13 |
# File 'lib/scorm/resource.rb', line 11 def files @files end |
#href ⇒ Object
Returns the value of attribute href.
9 10 11 |
# File 'lib/scorm/resource.rb', line 9 def href @href end |
#id ⇒ Object
Returns the value of attribute id.
6 7 8 |
# File 'lib/scorm/resource.rb', line 6 def id @id end |
#metadata ⇒ Object
Returns the value of attribute metadata.
10 11 12 |
# File 'lib/scorm/resource.rb', line 10 def @metadata end |
#scorm_type ⇒ Object
Returns the value of attribute scorm_type.
8 9 10 |
# File 'lib/scorm/resource.rb', line 8 def scorm_type @scorm_type end |
#type ⇒ Object
Returns the value of attribute type.
7 8 9 |
# File 'lib/scorm/resource.rb', line 7 def type @type end |
Class Method Details
.from_xml(element) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/scorm/resource.rb', line 28 def self.from_xml(element) = nil files = [] REXML::XPath.each(element, 'file') do |file_el| files << element.attribute('xml:base').to_s + file_el.attribute('href').to_s end dependencies = [] REXML::XPath.each(element, 'dependency') do |dep_el| dependencies << dep_el.attribute('identifierref').to_s end res = self.new( element.attribute('identifier'), element.attribute('type'), element.attribute('scormType', 'adlcp') || element.attribute('scormtype', 'adlcp'), element.attribute('xml:base').to_s + element.attribute('href').to_s, , files, dependencies) end |