class LUSI::API::Calendar::Week

Represents an academic week in the LUSI API

Attributes

att_identity[RW]

@!attribute [rw] att_identity

@return [Integer, nil] the academic timetable (ATT) week identity
monday_date[RW]

@!attribute [rw] monday_date

@return [DateTime, nil] the Monday starting the week
term[RW]

@!attribute [rw] term

@return [String, nil] The term/period the week is in
year[RW]

@!attribute [rw] year

@return [LUSI::API::Calendar::Year, nil] the academic year containing the week

Public Class Methods

get_current_academic_week(api = nil, lookup = nil) { |obj| ... } click to toggle source

Returns a Week instance for the current academic week @param api [LUSI::API::Core::API] the LUSI API instance @param lookup [LUSI::API::Core::Lookup::LookupService, nil] the lookup service for object resolution @return [LUSI::API::Calendar::Week] the current academic week @yield [obj] Passes the Week instance to the block @yieldparam obj [LUSI::API::Calendar::Week] the Week instance

# File lib/lusi_api/calendar.rb, line 36
def self.get_current_academic_week(api = nil, lookup = nil)
  xml = api.call('LUSIReference', 'General.asmx', 'GetCurrentAcademicWeek')
  obj = new(LUSI::API::Core::XML.xml_at(xml, 'xmlns:Week'), lookup)
  yield(obj) if block_given?
  obj
end
get_instance(api = nil, lookup = nil, use_lookup: true, year_identity: nil) { |week| ... } click to toggle source

Returns Week instances for all or one specific academic year @param api [LUSI::API::Core::API] the LUSI API instance @param lookup [LUSI::API::Core::Lookup::LookupService, nil] the lookup service for object resolution @param use_lookup [Boolean] if true, use the lookup service to identify instances before trying the API @param year [LUSI::API::Calendar::Year, String, nil] the academic year required (all defined weeks if nil) @return [Array<LUSI::API::Calendar::Week>] the selected acadmic weeks @yield [obj] Passes the Week instance to the block @yieldparam obj [LUSI::API::Calendar::Week] the Week instance

Calls superclass method LUSI::API::Core::Code::get_instance
# File lib/lusi_api/calendar.rb, line 51
def self.get_instance(api = nil, lookup = nil, use_lookup: true, year_identity: nil)
  # Search the lookup service
  if lookup and use_lookup
    week = lookup.lookup(:week, year_identity)
    if week
      yield(week) if block_given?
      return week
    end
  end
  # Search the API
  super(api, lookup, 'LUSIReference', 'General.asmx', 'GetWeeks', 'xmlns:Week', year_identity: year_identity)
end
new(xml = nil, lookup = nil, term: nil, monday_date: nil, year: nil, att_identity: nil, **kwargs) click to toggle source

Initialises a new Week instance @param (see LUSI::API::Core::Code#initialize) @param att_identity [Integer, nil] the default academic timetable (ATT) identity @param monday_date [DateTime, nil] the default Monday week-start date @param term [String, nil] the default term @param year [LUSI::API::Calendar::Year, nil] the default academic year @return [void]

Calls superclass method LUSI::API::Core::BasicCode::new
# File lib/lusi_api/calendar.rb, line 71
def initialize(xml = nil, lookup = nil, term: nil, monday_date: nil, year: nil, att_identity: nil, **kwargs)
  super(xml, lookup, **kwargs)
  @att_identity = LUSI::API::Core::XML.xml_int_at(xml, 'xmlns:ATTIdentity', att_identity)
  @monday_date = LUSI::API::Core::XML.xml_datetime_at(xml, 'xmlns:MondayDate', monday_date)
  @term = LUSI::API::Core::XML.xml_content_at(xml, 'xmlns:Term', term)
  @year = LUSI::API::Core::XML.lookup(xml, lookup, :year, 'xmlns:Year/xmlns:Identity', year)
end

Protected Class Methods

get_instance_params(**kwargs) click to toggle source
# File lib/lusi_api/calendar.rb, line 81
def self.get_instance_params(**kwargs)
  year = kwargs[:year_identity] || ''
  year = year.identity if year.is_a?(Year)
  params = super(**kwargs)
  params[:YearIdentity] = year || ''
  params
end