Class: LUSI::API::Course::CourseDocument

Inherits:
Object
  • Object
show all
Defined in:
lib/lusi_api/course.rb

Overview

Represents a course document in the LUSI API

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(xml = nil, lookup = nil, type: nil, html_text: nil) ⇒ void

Initialises a new CourseDocument instance

Parameters:

  • xml (Nokogiri::XML::Document, Nokogiri::XML::Node) (defaults to: nil)

    the parsed XML root of the course document

  • lookup (LUSI::API::Core::Lookup::LookupService, nil) (defaults to: nil)

    the lookup service for object resolution

  • type (LUSI::API::Core::Code, nil) (defaults to: nil)

    the default document type

  • html_text (String, nil) (defaults to: nil)

    the default document text



560
561
562
563
# File 'lib/lusi_api/course.rb', line 560

def initialize(xml = nil, lookup = nil, type: nil, html_text: nil)
  @type = LUSI::API::Core::Code.new(LUSI::API::Core::XML.xml_at(xml, 'xmlns:Type', type), lookup)
  @html_text = LUSI::API::Core::XML.xml_content_at(xml, 'xmlns:HTMLText', html_text)
end

Instance Attribute Details

#html_textString?

Returns the text document as pre-formatted HTML.

Returns:

  • (String, nil)

    the text document as pre-formatted HTML



552
553
554
# File 'lib/lusi_api/course.rb', line 552

def html_text
  @html_text
end

#typeLUSI::API::Core::Code?

Returns the course document type.

Returns:



548
549
550
# File 'lib/lusi_api/course.rb', line 548

def type
  @type
end

Instance Method Details

#to_sString

Returns a string representation of the CourseDocument instance

Returns:

  • (String)

    the string representation of the CourseDocument instance



567
568
569
# File 'lib/lusi_api/course.rb', line 567

def to_s
  @type.description
end