Class: Scorm::Metadata::Category

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

Class Method Summary collapse

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(sym, *args) ⇒ Object



43
44
45
46
47
48
49
50
# File 'lib/scorm/metadata.rb', line 43

def method_missing(sym, *args)
  data_element = self.fetch(sym.to_s, nil)
  if data_element.is_a? DataElement
    data_element.value(args.first)
  else
    data_element
  end
end

Class Method Details

.from_xml(element) ⇒ Object



35
36
37
38
39
40
41
# File 'lib/scorm/metadata.rb', line 35

def self.from_xml(element)
  category = Scorm::Metadata::Category.new
  element.elements.each do |data_el|
    category[data_el.name.to_s] = DataElement.from_xml(data_el)
  end
  return category
end