Class: Lti::ThinCommonCartridge

Inherits:
Object
  • Object
show all
Defined in:
lib/lti/thin_common_cartridge.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(items) ⇒ ThinCommonCartridge

Returns a new instance of ThinCommonCartridge.



10
11
12
13
14
15
16
17
# File 'lib/lti/thin_common_cartridge.rb', line 10

def initialize(items)
  @items = Array.wrap items
  @xml = File.open(File.expand_path MANIFEST_FILEPATH) { |f| Nokogiri::XML(f) }
  @link_template = File.open(File.expand_path LTI_LINK_FILEPATH) { |f| Nokogiri::XML(f) }
  @links = []

  create_nodes
end

Instance Attribute Details

Returns the value of attribute links.



8
9
10
# File 'lib/lti/thin_common_cartridge.rb', line 8

def links
  @links
end

Instance Method Details

#create_nodesObject



19
20
21
22
23
# File 'lib/lti/thin_common_cartridge.rb', line 19

def create_nodes
  # Build hierarchy of objects
  root_item = xml.at 'organizations/organization/item'
  items.each { |c| add_item c, root_item }
end

#manifestObject



25
26
27
# File 'lib/lti/thin_common_cartridge.rb', line 25

def manifest
  xml.to_xml
end