lib/api/Apply.js

  1. class Apply {
  2. /**
  3. * Creates an instance of Apply
  4. * @constructor
  5. * @param {Object} data - An object containing the attributes to define the apply.
  6. * @param {Array} parallax - An array of {Parallax} instances.
  7. * @example
  8. * // creates an Apply
  9. * const { Apply, Parallax } = require('lucid-dream');
  10. * const apply = new Apply({}, [ new Parallax() ]);
  11. * @property {Object} data - An Object containing the attributes of the apply.
  12. * @property {Array} parallax - An array of {@link Parallax} instances.
  13. */
  14. constructor(data, parallax) {
  15. this.data = data;
  16. this.parallax = parallax;
  17. }
  18. /**
  19. * Encode an Apply into a dictionary
  20. * @example
  21. * // returns encoded apply dictionary
  22. * const { Apply } = require('lucid-dream');
  23. * const apply = new Apply({}, [ new Parallax() ]);
  24. * apply.toDict();
  25. * @returns {Object} An object containing the encoded apply dicitonary
  26. */
  27. toDict() {
  28. const res = Object.assign({}, this.data);
  29. res.__name = 'apply';
  30. res.__children = this.parallax.map(p => p.toDict());
  31. return res;
  32. }
  33. }
  34. module.exports = Apply;