Commit abd49e3
Changed files (6)
lib/fizz_buzz.js
@@ -1,21 +0,0 @@
-// Generated by CoffeeScript 1.6.3
-var FizzBuzz;
-
-module.exports = FizzBuzz = (function() {
- function FizzBuzz() {}
-
- FizzBuzz.prototype.run = function(n) {
- var result;
- result = "";
- if (n % 3 === 0) {
- result += "Fizz";
- }
- if (n % 5 === 0) {
- result += "Buzz";
- }
- return result;
- };
-
- return FizzBuzz;
-
-})();
lib/greeting.js
@@ -1,19 +0,0 @@
-// Generated by CoffeeScript 1.6.3
-var Greeting;
-
-Greeting = (function() {
- function Greeting() {}
-
- Greeting.prototype.greet = function() {
- return "hello";
- };
-
- Greeting.prototype.say = function(message) {
- return message;
- };
-
- return Greeting;
-
-})();
-
-module.exports.Greeting = Greeting;
lib/movie.js
@@ -1,17 +0,0 @@
-// Generated by CoffeeScript 1.6.3
-var Movie;
-
-module.exports = Movie = (function() {
- function Movie(attributes) {
- this.title = attributes['title'];
- this.studio = attributes['studio'];
- this.year_published = attributes['year_published'];
- }
-
- Movie.prototype.equals = function(other) {
- return this.title === other["title"];
- };
-
- return Movie;
-
-})();
lib/movie_library.js
@@ -1,183 +0,0 @@
-// Generated by CoffeeScript 1.6.3
-var Enumerable, Module, MovieLibrary, Studio, moduleKeywords,
- __indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; },
- __hasProp = {}.hasOwnProperty,
- __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
-
-Studio = require('./studio');
-
-Enumerable = {
- any: function(predicate) {
- var result,
- _this = this;
- result = false;
- this.each(function(item) {
- result = predicate(item);
- if (result) {
-
- }
- });
- return result;
- },
- includes: function(other_item) {
- var result,
- _this = this;
- result = false;
- this.each(function(item) {
- return result || (result = item === other_item || item.equals(other_item));
- });
- return result;
- },
- find_all: function(predicate) {
- var results,
- _this = this;
- results = [];
- this.each(function(item) {
- if (predicate(item)) {
- return results.push(item);
- }
- });
- return results;
- }
-};
-
-moduleKeywords = ['extended', 'included'];
-
-Module = (function() {
- function Module() {}
-
- Module.include = function(object) {
- var key, value, _ref;
- for (key in object) {
- value = object[key];
- if (__indexOf.call(moduleKeywords, key) < 0) {
- this.prototype[key] = value;
- }
- }
- if ((_ref = object.included) != null) {
- _ref.apply(this);
- }
- return this;
- };
-
- return Module;
-
-})();
-
-module.exports = MovieLibrary = (function(_super) {
- __extends(MovieLibrary, _super);
-
- MovieLibrary.include(Enumerable);
-
- function MovieLibrary() {
- this.movies = [];
- }
-
- MovieLibrary.prototype.add = function(movie) {
- if (!this.includes(movie)) {
- return this.movies.push(movie);
- }
- };
-
- MovieLibrary.prototype.count = function() {
- return this.movies.length;
- };
-
- MovieLibrary.prototype.each = function(visitor) {
- var movie, _i, _len, _ref, _results;
- _ref = this.movies;
- _results = [];
- for (_i = 0, _len = _ref.length; _i < _len; _i++) {
- movie = _ref[_i];
- _results.push(visitor(movie));
- }
- return _results;
- };
-
- MovieLibrary.prototype.find_all_movies_by_pixar = function() {
- var _this = this;
- return this.find_all(function(movie) {
- return movie.studio === Studio.Pixar;
- });
- };
-
- MovieLibrary.prototype.find_movies_by_pixar_or_disney = function() {
- var _this = this;
- return this.find_all(function(movie) {
- return movie.studio === Studio.Pixar || movie.studio === Studio.Disney;
- });
- };
-
- MovieLibrary.prototype.find_movies_not_published_by_pixar = function() {
- var _this = this;
- return this.find_all(function(movie) {
- return movie.studio !== Studio.Pixar;
- });
- };
-
- MovieLibrary.prototype.find_movies_released_after_2004 = function() {
- var _this = this;
- return this.find_all(function(movie) {
- return movie.year_published > 2004;
- });
- };
-
- MovieLibrary.prototype.find_movies_released_between_1982_and_2003 = function() {
- var _this = this;
- return this.find_all(function(movie) {
- return movie.year_published > 1982 && movie.year_published < 2003;
- });
- };
-
- MovieLibrary.prototype.sort_by_title_ascending = function() {
- return this.movies.sort(function(x, y) {
- if (x.title > y.title) {
- return 1;
- }
- if (x.title < y.title) {
- return -1;
- }
- return 0;
- });
- };
-
- MovieLibrary.prototype.sort_by_title_descending = function() {
- return this.movies.sort(function(y, x) {
- if (x.title > y.title) {
- return 1;
- }
- if (x.title < y.title) {
- return -1;
- }
- return 0;
- });
- };
-
- MovieLibrary.prototype.sorted_by_year_published = function() {
- return this.movies.sort(function(x, y) {
- return x.year_published - y.year_published;
- });
- };
-
- MovieLibrary.prototype.sorted_by_year_published_descending = function() {
- return this.movies.sort(function(x, y) {
- return y.year_published - x.year_published;
- });
- };
-
- MovieLibrary.prototype.sorted_by_studio_rankings_then_by_year_published = function(rankings) {
- var _this = this;
- return this.movies.sort(function(x, y) {
- var result;
- result = rankings.indexOf(x.studio) - rankings.indexOf(y.studio);
- if (result === 0) {
- return x.year_published - y.year_published;
- } else {
- return result;
- }
- });
- };
-
- return MovieLibrary;
-
-})(Module);
lib/studio.js
@@ -1,10 +0,0 @@
-// Generated by CoffeeScript 1.6.3
-var Studio;
-
-module.exports = Studio = {
- CastleRock: "Castle Rock",
- MiramaxFilms: "Miramax Films",
- RegencyEnterprises: "Regency Enterprises",
- Pixar: "Pixar",
- Disney: "Disney"
-};
.gitignore
@@ -1,1 +1,2 @@
node_modules
+lib