artdaq_node_server  v1_00_08
 All Classes Namespaces Files Variables Pages
XMLDeclaration.js
1 // Generated by CoffeeScript 1.9.1
2 (function() {
3  var XMLDeclaration, XMLNode, create, isObject,
4  extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
5  hasProp = {}.hasOwnProperty;
6 
7  create = require('lodash/create');
8 
9  isObject = require('lodash/isObject');
10 
11  XMLNode = require('./XMLNode');
12 
13  module.exports = XMLDeclaration = (function(superClass) {
14  extend(XMLDeclaration, superClass);
15 
16  function XMLDeclaration(parent, version, encoding, standalone) {
17  var ref;
18  XMLDeclaration.__super__.constructor.call(this, parent);
19  if (isObject(version)) {
20  ref = version, version = ref.version, encoding = ref.encoding, standalone = ref.standalone;
21  }
22  if (!version) {
23  version = '1.0';
24  }
25  this.version = this.stringify.xmlVersion(version);
26  if (encoding != null) {
27  this.encoding = this.stringify.xmlEncoding(encoding);
28  }
29  if (standalone != null) {
30  this.standalone = this.stringify.xmlStandalone(standalone);
31  }
32  }
33 
34  XMLDeclaration.prototype.toString = function(options, level) {
35  var indent, newline, offset, pretty, r, ref, ref1, ref2, space;
36  pretty = (options != null ? options.pretty : void 0) || false;
37  indent = (ref = options != null ? options.indent : void 0) != null ? ref : ' ';
38  offset = (ref1 = options != null ? options.offset : void 0) != null ? ref1 : 0;
39  newline = (ref2 = options != null ? options.newline : void 0) != null ? ref2 : '\n';
40  level || (level = 0);
41  space = new Array(level + offset + 1).join(indent);
42  r = '';
43  if (pretty) {
44  r += space;
45  }
46  r += '<?xml';
47  r += ' version="' + this.version + '"';
48  if (this.encoding != null) {
49  r += ' encoding="' + this.encoding + '"';
50  }
51  if (this.standalone != null) {
52  r += ' standalone="' + this.standalone + '"';
53  }
54  r += '?>';
55  if (pretty) {
56  r += newline;
57  }
58  return r;
59  };
60 
61  return XMLDeclaration;
62 
63  })(XMLNode);
64 
65 }).call(this);