Class: LUSI::API::Course::Subject

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

Overview

Represents a subject in the LUSI API

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(xml = nil, lookup = nil, department: nil, group: nil, identity: nil, mnemonic: nil, title: nil) ⇒ void

Initialises a new Subject instance

Parameters:

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

    the parsed XML root of the subject

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

    the lookup table for department resolution

  • department (LUSI::API::Organisation::Unit, nil) (defaults to: nil)

    the default department

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

    the default group type

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

    the default identity code

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

    the default mnemonic

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

    the default title



998
999
1000
1001
1002
1003
1004
1005
# File 'lib/lusi_api/course.rb', line 998

def initialize(xml = nil, lookup = nil, department: nil, group: nil, identity: nil, mnemonic: nil, title: nil)
  @department = LUSI::API::Core::XML.lookup(xml, lookup, :department, 'xmlns:Department/xmlns:Identity',
                                            department)
  @group = LUSI::API::Core::XML.xml_content_at(xml, 'xmlns:Group', group)
  @identity = LUSI::API::Core::XML.xml_content_at(xml, 'xmlns:Identity', identity)
  @mnemonic = LUSI::API::Core::XML.xml_content_at(xml, 'xmlns:Mnemonic', mnemonic)
  @title = LUSI::API::Core::XML.xml_content_at(xml, 'xmlns:Title', title)
end

Instance Attribute Details

#departmentLUSI::API::Organisation::Unit?

Returns the department associated with the subject.

Returns:



987
988
989
# File 'lib/lusi_api/course.rb', line 987

def department
  @department
end

#groupString?

Returns the group type of the subject.

Returns:

  • (String, nil)

    the group type of the subject



983
984
985
# File 'lib/lusi_api/course.rb', line 983

def group
  @group
end

#identityString?

Returns the identity code of the subject.

Returns:

  • (String, nil)

    the identity code of the subject



971
972
973
# File 'lib/lusi_api/course.rb', line 971

def identity
  @identity
end

#mnemonicString?

Returns the mnemonic for the subject.

Returns:

  • (String, nil)

    the mnemonic for the subject



975
976
977
# File 'lib/lusi_api/course.rb', line 975

def mnemonic
  @mnemonic
end

#titleString?

Returns the title of the subject.

Returns:

  • (String, nil)

    the title of the subject



979
980
981
# File 'lib/lusi_api/course.rb', line 979

def title
  @title
end

Instance Method Details

#to_sString

Returns a string representation of the Subject instance

Returns:

  • (String)

    the string representationn of the Subject instance



1009
1010
1011
# File 'lib/lusi_api/course.rb', line 1009

def to_s
  @title
end