class LUSI::API::Course::Cohort

Represents a cohort (student intake) in the LUSI API

Attributes

display_long_title[RW]

@!attribute [rw] display_long_title

@return [String, nil] the long title of the cohort
display_short_title[RW]

@!attribute [rw] display_short_title

@return [String, nil] the short title of the cohort
end_date[RW]

@!attribute [rw] end_date

@return [DateTime, nil] the end date of study
identity[RW]

@!attribute [rw] identity

@return [Integer, nil] the identity code of the cohort
start_date[RW]

@!attribute [rw] start_date

@return [DateTime, nil] the start date of study

Public Class Methods

new(xml = nil, lookup = nil, display_long_title: nil, display_short_title: nil, end_date: nil, identity: nil, start_date: nil) click to toggle source

Initialises a new Cohort instance @param xml [Nokogiri::XML::Document, Nokogiri::XML::Node] the parsed XML root of the cohort @param lookup [LUSI::API::Core::Lookup::LookupService, nil] the lookup service for object resolution @param display_long_title [String, nil] the default long title @param display_short_title [String, nil] the default short title @param end_date [DateTime, nil] the default end-of-study date @param identity [Integer, nil] the default identity code @param start_date [DateTime, nil] the default start-of-study date @return [void]

# 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

Public Instance Methods

to_s() click to toggle source

Returns a string representation of the Cohort instance @return [String] the string representation of the Cohort instance

# 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