Skip to content

Instantly share code, notes, and snippets.

@ParthBarot-BoTreeConsulting
Last active August 29, 2015 14:07
Show Gist options
  • Save ParthBarot-BoTreeConsulting/f9039d96dc4ccccf88ab to your computer and use it in GitHub Desktop.
Save ParthBarot-BoTreeConsulting/f9039d96dc4ccccf88ab to your computer and use it in GitHub Desktop.
Create Javascript class using coffe script
this.Elijah ?= {}
class TemperaturesController
constructor: (@opts) ->
console.log "temps init!"
index: ->
console.log "temps index!"
console.log @opts
this.Elijah.temperatures = new TemperaturesController([1,2,3])
this.Elijah.temperatures1 = new TemperaturesController([3,5,6])
this.Elijah.temperatures.index()
this.Elijah.temperatures1.index()
var TemperaturesController;
if (this.Elijah == null) {
this.Elijah = {};
}
TemperaturesController = (function() {
function TemperaturesController(opts) {
this.opts = opts;
console.log("temps init!");
}
TemperaturesController.prototype.index = function() {
console.log("temps index!");
return console.log(this.opts);
};
return TemperaturesController;
})();
this.Elijah.temperatures = new TemperaturesController([1, 2, 3]);
this.Elijah.temperatures1 = new TemperaturesController([3, 5, 6]);
this.Elijah.temperatures.index();
this.Elijah.temperatures1.index();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment