Sha256: fea9aa0a2ab1f1e9df139d2c9f2eecdb670d2a744c42958d64ac3c9fee296038

Contents?: true

Size: 1.03 KB

Versions: 60

Compression:

Stored size: 1.03 KB

Contents

this.Phone = (function() {
  function Phone(area_code, number) {
    var _ref;

    this.area_code = area_code;
    this.number = number;
    if (typeof this.area_code === 'object') {
      _ref = this.area_code, this.area_code = _ref.area_code, this.number = _ref.number;
    }
    if (!this.number) {
      this.number = this.area_code;
      this.area_code = null;
    }
    Object.defineProperty(this, 'valid', {
      get: this.validate
    });
  }

  Phone.prototype.validate = function() {
    return (this.area_code != null) && (this.number != null);
  };

  Phone.prototype.toString = function() {
    var formatted_number;

    if (this.number != null) {
      formatted_number = this.number.substr(0, 4) + '-' + this.number.substr(4);
    }
    if (this.area_code != null) {
      return "(" + this.area_code + ") " + formatted_number;
    } else {
      return formatted_number;
    }
  };

  Phone.prototype.toJSON = function() {
    return {
      area_code: this.area_code,
      number: this.number
    };
  };

  return Phone;

})();

Version data entries

60 entries across 60 versions & 1 rubygems

Version Path
ende-0.5.22 components/indefinido/indemma/master/spec/support/value_objects/phone.js
ende-0.5.21 components/indefinido/indemma/master/spec/support/value_objects/phone.js
ende-0.4.25 vendor/components/indefinido-indemma/spec/support/value_objects/phone.js
ende-0.4.24 vendor/components/indefinido-indemma/spec/support/value_objects/phone.js
ende-0.4.23 vendor/components/indefinido-indemma/spec/support/value_objects/phone.js
ende-0.5.1 components/indefinido/indemma/master/spec/support/value_objects/phone.js
ende-0.4.22 vendor/components/indefinido-indemma/spec/support/value_objects/phone.js
ende-0.4.21 vendor/components/indefinido-indemma/spec/support/value_objects/phone.js
ende-0.5.0 vendor/components/indefinido-indemma/spec/support/value_objects/phone.js
ende-0.4.20 vendor/components/indefinido-indemma/spec/support/value_objects/phone.js
ende-0.4.19 vendor/components/indefinido-indemma/spec/support/value_objects/phone.js
ende-0.4.18 vendor/components/indefinido-indemma/spec/support/value_objects/phone.js
ende-0.4.17 vendor/components/indefinido-indemma/spec/support/value_objects/phone.js
ende-0.4.16 vendor/components/indefinido-indemma/spec/support/value_objects/phone.js
ende-0.3.13 vendor/components/indefinido-indemma/spec/support/value_objects/phone.js
ende-0.3.12 vendor/components/indefinido-indemma/spec/support/value_objects/phone.js
ende-0.3.11 vendor/components/indefinido-indemma/spec/support/value_objects/phone.js
ende-0.4.15 vendor/components/indefinido-indemma/spec/support/value_objects/phone.js
ende-0.4.14 vendor/components/indefinido-indemma/spec/support/value_objects/phone.js
ende-0.4.13 vendor/components/indefinido-indemma/spec/support/value_objects/phone.js