Skip to content

Instantly share code, notes, and snippets.

@amiel
Created January 28, 2010 07:06
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 amiel/288512 to your computer and use it in GitHub Desktop.
Save amiel/288512 to your computer and use it in GitHub Desktop.
var MyClass = (function(){
var private_var = "private variable", self;
function initialize(a,b) {
self = this; // self gives access to "this" for private functions
this.a = a;
this.b = private_function(b);
print(this.a,this.b);
}
function private_function(a) {
return a.toUpperCase();
}
function print(a,b) {
Ruby.puts(self.a,a,b, private_var);
}
initialize.prototype.public_function = function(c) {
print(c, self.b);
};
return initialize;
})();
var test = new MyClass('foo', 'bar');
Ruby.puts("\n");
test.public_function("foobaz");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment