Sha256: 753c70b0f9ae9e6846583e9fa532dc7dd7d4b20e13697b07a81f0f52415ee051

Contents?: true

Size: 1.25 KB

Versions: 7

Compression:

Stored size: 1.25 KB

Contents

// ==========================================================================
// Project:   SproutCore Costello - Property Observing Library
// Copyright: ©2006-2009 Sprout Systems, Inc. and contributors.
//            Portions ©2008-2009 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

7 entries across 7 versions & 1 rubygems

Version Path
sproutcore-1.4.0.rc.5 lib/frameworks/sproutcore/frameworks/runtime/mixins/comparable.js
sproutcore-1.4.0.rc.4 lib/frameworks/sproutcore/frameworks/runtime/mixins/comparable.js
sproutcore-1.4.0.rc.3 lib/frameworks/sproutcore/frameworks/runtime/mixins/comparable.js
sproutcore-1.4.0.rc.2 lib/frameworks/sproutcore/frameworks/runtime/mixins/comparable.js
sproutcore-1.4.0.rc lib/frameworks/sproutcore/frameworks/runtime/mixins/comparable.js
sproutcore-1.0.1049.pre.2 lib/frameworks/sproutcore/frameworks/runtime/mixins/comparable.js
sproutcore-1.0.1049.pre.1 frameworks/sproutcore/frameworks/runtime/mixins/comparable.js