Class: LUSI::API::Course::Identity

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

Overview

Represents the identity of a module or scheme of study

Direct Known Subclasses

EnrolmentIdentity

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(xml = nil, lookup = nil, asp: nil, course: nil, year: nil) ⇒ void

Initialises a new Identity instance

Parameters:

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

    the parsed XML root of the identity

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

    the lookup service for object resolution

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

    the default academically-significant period (ASP)

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

    the default identity of the module or schemem of study

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

    the default academic year identity code



36
37
38
39
40
# File 'lib/lusi_api/course.rb', line 36

def initialize(xml = nil, lookup = nil, asp: nil, course: nil, year: nil)
  @asp = LUSI::API::Core::XML.xml_content_at(xml, 'xmlns:ASP', asp)
  @course = LUSI::API::Core::XML.xml_content_at(xml, 'xmlns:Course', course)
  @year = LUSI::API::Core::XML.xml_content_at(xml, 'xmlns:Year', year)
end

Instance Attribute Details

#aspString?

Returns the academically-significant period (ASP).

Returns:

  • (String, nil)

    the academically-significant period (ASP)



19
20
21
# File 'lib/lusi_api/course.rb', line 19

def asp
  @asp
end

#courseString?

Returns the identity code of the module or scheme of study.

Returns:

  • (String, nil)

    the identity code of the module or scheme of study



23
24
25
# File 'lib/lusi_api/course.rb', line 23

def course
  @course
end

#yearString?

Returns the identity code of the academic year.

Returns:

  • (String, nil)

    the identity code of the academic year



27
28
29
# File 'lib/lusi_api/course.rb', line 27

def year
  @year
end

Instance Method Details

#lookup_keyString

Returns a string suitable for use as a hash lookup key

Returns:

  • (String)

    the lookup key



44
45
46
# File 'lib/lusi_api/course.rb', line 44

def lookup_key
  "#{course}-#{year}"
end

#to_sString

Returns a string representation of the Identity instance

Returns:

  • (String)

    the string representation of the Identity instance



50
51
52
# File 'lib/lusi_api/course.rb', line 50

def to_s
  "lusi-#{lookup_key}"
end