Created
September 23, 2011 05:32
-
-
Save 525c1e21-bd67-4735-ac99-b4b0e5262290/1236803 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
db = {} | |
class Drink | |
constructor: ({@spirit, @mixer}, args = {}) -> | |
@additives = [] | |
@additives.push db.ice if args.ice | |
class Fluid | |
constructor: (@name, args = {}) -> | |
@frozen = args.frozen or no | |
class Mixer extends Fluid | |
constructor: -> super | |
class Spirit extends Fluid | |
constructor: -> super | |
db.ice = new Fluid 'Water', frozen: yes | |
db.spirits = cc: new Spirit 'Canadian Club' | |
db.mixers = | |
dry: new Mixer 'Dry Ginger Ale' | |
coke: new Mixer 'Coca-Cola' | |
(require 'http').createServer((req, res) -> | |
res.writeHead 200, 'Content-Type': 'text/plain' | |
res.end (JSON.stringify new Drink spirit: db.spirits.cc, mixer: db.mixers[req.params.mixer], ice: req.params.ice) | |
).listen 1337, 'localhost' | |
console.log 'Canadian Club being served at http://localhost:1337/' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment