Class: LUSIAlmaCourseLoader::Reader

Inherits:
AlmaCourseLoader::Reader
  • Object
show all
Includes:
Helpers
Defined in:
lib/lusi_alma_course_loader/reader.rb

Overview

Reads course information from LUSI

Constant Summary collapse

PROCESSING_DEPARTMENT =

Alma processing department code

'Library'.freeze
TERMS =

Alma term codes

{
  lusi_lent: 'LENT',
  lusi_mich: 'MICHAELMAS',
  lusi_summ: 'SUMMER'
}.freeze

Constants included from Helpers

Helpers::COURSE_ID_OFFSETS, Helpers::INSTRUCTOR_ROLES

Instance Method Summary collapse

Methods included from Helpers

#course_department, #course_id, #department, #departments, #field, #instructor_enrolments, #instructor_roles, #instructor_usernames, #org_units

Constructor Details

#initialize(lusi_api = nil, lusi_lookup = nil, *years, **kwargs) ⇒ void

Initializes a new Reader instance

Parameters:

  • lusi_api (LUSI::API::Core::API) (defaults to: nil)

    the LUSI API instance

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

    the LUSI lookup service



172
173
174
175
176
177
178
179
# File 'lib/lusi_alma_course_loader/reader.rb', line 172

def initialize(lusi_api = nil, lusi_lookup = nil, *years, **kwargs)
  # Set the LUSI API and lookup properties for use with subsequent methods
  @lusi_api = lusi_api
  @lusi_lookup = lusi_lookup
  super(*years, **kwargs)
  @departments = departments
  @instructor_roles = instructor_roles
end

Instance Method Details

#years(year = nil, years_previous: nil, years_next: nil) ⇒ Object

Returns a list of LUSI year instances

Parameters:

  • year (LUSI::API::Calendar::Year) (defaults to: nil)

    the base year (defaults to the current academic year)

  • years_previous (Integer) (defaults to: nil)

    the number of years preceding the base year

  • years_next (Integer) (defaults to: nil)

    the number of years following the base year



187
188
189
190
191
192
193
194
# File 'lib/lusi_alma_course_loader/reader.rb', line 187

def years(year = nil, years_previous: nil, years_next: nil)
  years_next = years_next.to_i
  years_previous = years_previous.to_i
  result = []
  result.push(*(year.previous(years_previous))) if years_previous > 0
  result.push(*(year.next(years_next))) if years_next > 0
  result
end