summaryrefslogtreecommitdiffstats
path: root/lib/models/glossaryEntry.js
blob: 10791db1d70fb1660c9a77febe33f25b7bb8e397 (plain)
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
var Immutable = require('immutable');
var slug = require('github-slugid');

/*
    A definition represents an entry in the glossary
*/

var GlossaryEntry = Immutable.Record({
    name:               String(),
    description:        String()
});

GlossaryEntry.prototype.getName = function() {
    return this.get('name');
};

GlossaryEntry.prototype.getDescription = function() {
    return this.get('description');
};


/**
    Get identifier for this entry

    @retrun {Boolean}
*/
GlossaryEntry.prototype.getID = function() {
    return GlossaryEntry.nameToID(this.getName());
};


/**
    Normalize a glossary entry name into a unique id

    @param {String}
    @return {String}
*/
GlossaryEntry.nameToID = function nameToID(name) {
    return slug(name);
};


module.exports = GlossaryEntry;