Skip to content

Instantly share code, notes, and snippets.

@kangax
Created October 10, 2008 20:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kangax/16153 to your computer and use it in GitHub Desktop.
Save kangax/16153 to your computer and use it in GitHub Desktop.
/*
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