Class: LUSI::API::Calendar::Week
- Inherits:
-
LUSI::API::Core::Code
- Object
- LUSI::API::Core::BasicCode
- LUSI::API::Core::Code
- LUSI::API::Calendar::Week
- Defined in:
- lib/lusi_api/calendar.rb
Overview
Represents an academic week in the LUSI API
Instance Attribute Summary collapse
-
#att_identity ⇒ Integer?
The academic timetable (ATT) week identity.
-
#monday_date ⇒ DateTime?
The Monday starting the week.
-
#term ⇒ String?
The term/period the week is in.
-
#year ⇒ LUSI::API::Calendar::Year?
The academic year containing the week.
Attributes inherited from LUSI::API::Core::BasicCode
Class Method Summary collapse
-
.get_current_academic_week(api = nil, lookup = nil) {|obj| ... } ⇒ LUSI::API::Calendar::Week
Returns a Week instance for the current academic week.
-
.get_instance(api = nil, lookup = nil, use_lookup: true, year_identity: nil) {|obj| ... } ⇒ Array<LUSI::API::Calendar::Week>
Returns Week instances for all or one specific academic year.
Instance Method Summary collapse
-
#initialize(xml = nil, lookup = nil, term: nil, monday_date: nil, year: nil, att_identity: nil, **kwargs) ⇒ void
constructor
Initialises a new Week instance.
Methods inherited from LUSI::API::Core::BasicCode
Constructor Details
#initialize(xml = nil, lookup = nil, term: nil, monday_date: nil, year: nil, att_identity: nil, **kwargs) ⇒ void
Initialises a new Week instance
71 72 73 74 75 76 77 |
# 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 |
Instance Attribute Details
#att_identity ⇒ Integer?
Returns the academic timetable (ATT) week identity.
16 17 18 |
# File 'lib/lusi_api/calendar.rb', line 16 def att_identity @att_identity end |
#monday_date ⇒ DateTime?
Returns the Monday starting the week.
20 21 22 |
# File 'lib/lusi_api/calendar.rb', line 20 def monday_date @monday_date end |
#term ⇒ String?
Returns The term/period the week is in.
24 25 26 |
# File 'lib/lusi_api/calendar.rb', line 24 def term @term end |
#year ⇒ LUSI::API::Calendar::Year?
Returns the academic year containing the week.
28 29 30 |
# File 'lib/lusi_api/calendar.rb', line 28 def year @year end |
Class Method Details
.get_current_academic_week(api = nil, lookup = nil) {|obj| ... } ⇒ LUSI::API::Calendar::Week
Returns a Week instance for the current academic week
36 37 38 39 40 41 |
# 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) {|obj| ... } ⇒ Array<LUSI::API::Calendar::Week>
Returns Week instances for all or one specific academic year
51 52 53 54 55 56 57 58 59 60 61 62 |
# 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 |