-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGreekCategory.gs
64 lines (54 loc) · 2 KB
/
GreekCategory.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
var Model = Model || {};
/**
* Constructs a new category specifically for categories for Greek Life Students.
*
* @param {String} categoryName
* The category name, used when identifying the category and even creating a spreadsheet
* for it.
* @constructor
*/
Model.GreekCategory = function (categoryName) {
/**
* 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 greekIndex = headers.indexOf('Greek');
// sanity check, if the index is missing, we just indicate that it is not a match.
if (greekIndex === -1) {
return false;
}
var greekValue = rowToMatch[greekIndex];
var yearInSchoolIndex = headers.indexOf('Year in School');
// sanity check, if the index is missing, we just indicate that it is not a match.
if (yearInSchoolIndex === -1) {
return false;
}
var yearInSchoolValue = rowToMatch[yearInSchoolIndex];
return yearInSchoolValue != 'Freshman' && greekValue != 'no';
};
/**
* The category name, used when identifying the category and even creating a spreadsheet
* for it.
*
* @type {String}
*/
this.categoryName = categoryName;
/**
* 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;
};