Class: Qti::V1::Models::StimulusItem

Inherits:
Base show all
Defined in:
lib/qti/v1/models/stimulus_item.rb

Instance Attribute Summary

Attributes inherited from Models::Base

#doc, #manifest, #package_root, #path, #resource

Instance Method Summary collapse

Methods inherited from Base

#qti_version, #return_inner_content!

Methods inherited from Models::Base

#css_with_single_check, from_path!, #parse_html, #parse_xml, #preprocess_xml_doc, #raise_unsupported, #remap_href_path, #sanitize_content!, #xpath_with_single_check

Constructor Details

#initialize(ref_node) ⇒ StimulusItem

Returns a new instance of StimulusItem.



5
6
7
# File 'lib/qti/v1/models/stimulus_item.rb', line 5

def initialize(ref_node)
  @node = ref_node
end

Instance Method Details

#bodyObject



17
18
19
20
21
22
23
# File 'lib/qti/v1/models/stimulus_item.rb', line 17

def body
  @body ||= begin
    presentation = @node.at_xpath('.//xmlns:presentation')
    return nil if presentation.blank?
    sanitize_content!(presentation.at_xpath('.//xmlns:mattext')&.text)
  end
end

#identifierObject



9
10
11
# File 'lib/qti/v1/models/stimulus_item.rb', line 9

def identifier
  @identifier ||= @node.attributes['ident']&.value
end

#stimulus_typeObject



25
26
27
# File 'lib/qti/v1/models/stimulus_item.rb', line 25

def stimulus_type
  'text'
end

#titleObject



13
14
15
# File 'lib/qti/v1/models/stimulus_item.rb', line 13

def title
  @title ||= @node.attributes['title']&.value
end