Created
October 10, 2008 20:44
-
-
Save kangax/16153 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
var p = CObject.init().setLeft(100); | |
p.left; // undefined | |
p.getLeft(); 100 | |
*/ | |
var CObject = (function(){ | |
return { | |
init: function(options) { | |
var __instance = { }, __public; | |
// basic accessors | |
// left | |
function getLeft(){ | |
return __instance.left; | |
} | |
function setLeft(left){ | |
__instance.left = left; | |
return __public; | |
} | |
// top | |
function getTop(){ | |
return __instance.left; | |
} | |
function setTop(left){ | |
__instance.left = left; | |
return __public; | |
} | |
// width | |
function getWidth(){ | |
return __instance.width; | |
} | |
function setWidth(width){ | |
__instance.width = width; | |
return __public; | |
} | |
// height | |
function getHeight(){ | |
return __instance.height; | |
} | |
function setHeight(height){ | |
__instance.height = height; | |
return __public; | |
} | |
// public "interface" | |
return (__public = { | |
getLeft: getLeft, | |
setLeft: setLeft, | |
getTop: getTop, | |
setTop: setTop. | |
getWidth: getWidth, | |
setWidth: setWidth, | |
getHeight: getHeight, | |
setHeight: setHeight | |
}); | |
} | |
} | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment