Class: LUSI::API::Course::Cohort

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

Overview

Represents a cohort (student intake) in the LUSI API

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(xml = nil, lookup = nil, display_long_title: nil, display_short_title: nil, end_date: nil, identity: nil, start_date: nil) ⇒ void

Initialises a new Cohort instance

Parameters:

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

    the parsed XML root of the cohort

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

    the lookup service for object resolution

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

    the default long title

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

    the default short title

  • end_date (DateTime, nil) (defaults to: nil)

    the default end-of-study date

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

    the default identity code

  • start_date (DateTime, nil) (defaults to: nil)

    the default start-of-study date



487
488
489
490
491
492
493
494
# File 'lib/lusi_api/course.rb', line 487

def initialize(xml = nil, lookup = nil, display_long_title: nil, display_short_title: nil, end_date: nil,
               identity: nil, start_date: nil)
  @display_long_title = LUSI::API::Core::XML.xml_content_at(xml, 'xmlns:DisplayLongTitle', display_long_title)
  @display_short_title = LUSI::API::Core::XML.xml_content_at(xml, 'xmlns:DisplayShortTitle', display_short_title)
  @end_date = LUSI::API::Core::XML.xml_datetime_at(xml, 'xmlns:EndDate', end_date)
  @identity = LUSI::API::Core::XML.xml_int_at(xml, 'xmlns:Identity', identity)
  @start_date = LUSI::API::Core::XML.xml_datetime_at(xml, 'xmlns:StartDate', start_date)
end

Instance Attribute Details

#display_long_titleString?

Returns the long title of the cohort.

Returns:

  • (String, nil)

    the long title of the cohort



460
461
462
# File 'lib/lusi_api/course.rb', line 460

def display_long_title
  @display_long_title
end

#display_short_titleString?

Returns the short title of the cohort.

Returns:

  • (String, nil)

    the short title of the cohort



464
465
466
# File 'lib/lusi_api/course.rb', line 464

def display_short_title
  @display_short_title
end

#end_dateDateTime?

Returns the end date of study.

Returns:

  • (DateTime, nil)

    the end date of study



468
469
470
# File 'lib/lusi_api/course.rb', line 468

def end_date
  @end_date
end

#identityInteger?

Returns the identity code of the cohort.

Returns:

  • (Integer, nil)

    the identity code of the cohort



472
473
474
# File 'lib/lusi_api/course.rb', line 472

def identity
  @identity
end

#start_dateDateTime?

Returns the start date of study.

Returns:

  • (DateTime, nil)

    the start date of study



476
477
478
# File 'lib/lusi_api/course.rb', line 476

def start_date
  @start_date
end

Instance Method Details

#to_sString

Returns a string representation of the Cohort instance

Returns:

  • (String)

    the string representation of the Cohort instance



498
499
500
501
502
# File 'lib/lusi_api/course.rb', line 498

def to_s
  end_date = @end_date ? @end_date.strftime('%d-%m-%Y') : ''
  start_date = @start_date ? @start_date.strftime('%d-%m-%Y') : ''
  "#{@display_long_title || @display_short_title} #{start_date}-#{end_date}"
end