Class: Scorm::Metadata

Inherits:
Hash
  • Object
show all
Defined in:
lib/scorm/metadata.rb

Overview

The Metadata class holds meta data associated with a SCORM package in a hash like structure. The Metadata class reads a LOM (Learning Object Metadata) structure and stores the data in categories. A Category can contain any number of DataElements. A DataElement behaves just like a string but can contain the same value in many different languages, accessed by the DataElement#value (or DataElement#to_s) method by specifying the language code as the first argument.

Ex.

<tt>pkg.manifest.metadata.general.class -> Metadata::Category</tt>
<tt>pkg.manifest.metadata.general.title.class -> Metadata::DataElement</tt>
<tt>pkg.manifest.metadata.general.title.value -> 'My course'</tt>
<tt>pkg.manifest.metadata.general.title.value('sv') -> 'Min kurs'</tt>

Defined Under Namespace

Classes: Category, DataElement

Class Method Summary collapse

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(sym) ⇒ Object



29
30
31
# File 'lib/scorm/metadata.rb', line 29

def method_missing(sym)
  self.fetch(sym.to_s, nil)
end

Class Method Details

.from_xml(element) ⇒ Object



20
21
22
23
24
25
26
27
# File 'lib/scorm/metadata.rb', line 20

def self.from_xml(element)
   = self.new
  element.elements.each do |category_el|
    category = Category.from_xml(category_el)
    .store(category_el.name.to_s, category)
  end
  return 
end