Sha256: 782dad08270a258174b433d749b0a3c76f1c9224107fc9a28366593ba7df3984

Contents?: true

Size: 1.22 KB

Versions: 5

Compression:

Stored size: 1.22 KB

Contents

// ==========================================================================
// Project:   SproutCore Costello - Property Observing Library
// Copyright: ©2006-2011 Strobe Inc. and contributors.
//            Portions ©2008-2010 Apple Inc. All rights reserved.
// License:   Licensed under MIT license (see license.js)
// ==========================================================================

/**
  @namespace

  Implements some standard methods for comparing objects. Add this mixin to
  any class you create that can compare its instances.

  You should implement the compare() method.

  @since SproutCore 1.0
*/
SC.Comparable = {

  /**
    walk like a duck. Indicates that the object can be compared.

    @type Boolean
  */
  isComparable: YES,

  /**
    Override to return the result of the comparison of the two parameters. The
    compare method should return
      -1 if a < b
       0 if a == b
       1 if a > b

    Default implementation raises
    an exception.

    @param a {Object} the first object to compare
    @param b {Object} the second object to compare
    @returns {Integer} the result of the comparison
  */
  compare: function(a, b) {
    throw "%@.compare() is not implemented".fmt(this.toString());
  }

};

Version data entries

5 entries across 5 versions & 2 rubygems

Version Path
spade-0.0.1 sproutcore/frameworks/runtime/mixins/comparable.js
sproutcore-1.5.0.pre.5 lib/frameworks/sproutcore/frameworks/runtime/mixins/comparable.js
sproutcore-1.5.0.pre.4.1 lib/frameworks/sproutcore/frameworks/runtime/mixins/comparable.js
sproutcore-1.5.0.pre.4 lib/frameworks/sproutcore/frameworks/runtime/mixins/comparable.js
sproutcore-1.5.0.pre.3 lib/frameworks/sproutcore/frameworks/runtime/mixins/comparable.js