Method: Qti::Models::Base#initialize

Defined in:
lib/qti/models/base.rb

#initialize(path:, package_root: nil, html: false, resource: nil) ⇒ Base

Returns a new instance of Base.

Raises:

  • (ArgumentError)


23
24
25
26
27
28
29
30
# File 'lib/qti/models/base.rb', line 23

def initialize(path:, package_root: nil, html: false, resource: nil)
  @path = path
  @resource = resource
  self.package_root = package_root || File.dirname(path)
  @doc = html ? parse_html(File.read(path)) : parse_xml(File.read(path))
  raise ArgumentError unless @doc
  preprocess_xml_doc(@doc) unless html
end