2015-09-10 14:13:12 +01:00
|
|
|
/**
|
|
|
|
Abstract character/resume sheet representation.
|
|
|
|
@license Copyright (c) 2015 by James M. Devlin. All rights reserved.
|
|
|
|
*/
|
2015-09-09 04:05:12 +01:00
|
|
|
|
2015-09-10 14:13:12 +01:00
|
|
|
(function() {
|
2015-09-09 04:05:12 +01:00
|
|
|
|
2015-09-10 14:13:12 +01:00
|
|
|
var FS = require('fs');
|
2015-09-17 00:32:42 +01:00
|
|
|
var extend = require('./extend');
|
2015-09-09 04:05:12 +01:00
|
|
|
|
2015-09-10 14:13:12 +01:00
|
|
|
function Sheet() {
|
|
|
|
this.id = null;
|
|
|
|
this.title = "New";
|
|
|
|
this.rep = { };
|
|
|
|
this.fileName = null;
|
|
|
|
}
|
2015-09-09 04:05:12 +01:00
|
|
|
|
2015-09-17 12:27:30 +01:00
|
|
|
/**
|
|
|
|
Open and parse the specified JSON resume sheet.
|
|
|
|
*/
|
2015-09-10 14:13:12 +01:00
|
|
|
Sheet.prototype.open = function( file, title ) {
|
2015-09-17 00:32:42 +01:00
|
|
|
var rep = JSON.parse( FS.readFileSync( file, 'utf8' ) );
|
|
|
|
extend( true, this, rep );
|
|
|
|
console.log( this );
|
2015-09-10 14:13:12 +01:00
|
|
|
this.fileName = file;
|
2015-09-17 00:32:42 +01:00
|
|
|
this.title = title || this.basics.name;
|
2015-09-10 14:13:12 +01:00
|
|
|
return this;
|
|
|
|
};
|
2015-09-09 04:05:12 +01:00
|
|
|
|
2015-09-17 12:27:30 +01:00
|
|
|
/**
|
|
|
|
Determine if the sheet includes a specific social profile (eg, GitHub).
|
|
|
|
*/
|
|
|
|
Sheet.prototype.hasProfile = function( socialNetwork ) {
|
|
|
|
socialNetwork = socialNetwork.trim().toLowerCase();
|
|
|
|
return this.basics.profiles && this.basics.profiles.filter(function(prof) {
|
|
|
|
return prof.network.trim().toLowerCase() === socialNetwork;
|
|
|
|
}).length > 0;
|
|
|
|
}
|
|
|
|
|
2015-09-10 14:13:12 +01:00
|
|
|
module.exports = Sheet;
|
2015-09-09 04:05:12 +01:00
|
|
|
|
|
|
|
}());
|