-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathResidenceHallCategory.gs
66 lines (58 loc) · 2.22 KB
/
ResidenceHallCategory.gs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
var Model = Model || {};
/**
* Constructs a new category specifically for categories based off of the residence hall.
*
* @param {String} categoryName
* The category name, used when identifying the category and even creating a spreadsheet
* for it.
* @param {String[]} residenceHallNames
* The different names of the residence halls that this specific category will match to.
* This could be a single value or multiple values.
* @constructor
*/
Model.ResidenceHallCategory = function (categoryName, residenceHallNames) {
/**
* Determines whether or not the current entry matches the specified value.
*
* @param {String[]} headers
* The headers, which will help to associate the values in the rowToMatch parameter with the
* meaning of the values. Basically, the 0th value in the headers would match the 0th value
* in the rowToMatch.
* @param rowToMatch
* The row that the current match is being performed on. This value and the corresponding
* header should be checked to determined if the value matches.
*
* @return {boolean} true if the entry in the rowToMatch parameter should be included in this
* category, false otherwise.
*/
this.matches = function (headers, rowToMatch) {
var residenceHallIndex = headers.indexOf('Residence Hall');
// sanity check, if the index is missing, we just indicate that it is not a match.
if (residenceHallIndex === -1) {
return false;
}
var residenceHallValue = rowToMatch[residenceHallIndex];
return this.residenceHallNames.indexOf(residenceHallValue) !== -1;
};
/**
* The category name, used when identifying the category and even creating a spreadsheet
* for it.
*
* @type {String}
*/
this.categoryName = categoryName;
/**
* The different names of the residence halls that this specific category will match to. This
* could be a single value or multiple values.
*
* @type {String[]}
*/
this.residenceHallNames = residenceHallNames;
/**
* The spreadsheet associated to this category. This value might not be initialized and should
* be accessed defensively.
*
* @type {null|GoogleAppsScript.Spreadsheet.Spreadsheet}
*/
this.spreadsheet = null;
};