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
| { | |
| "name": "rails_webpack_npm_es6", | |
| "version": "1.0.0", | |
| "main": "app-js/main.js", | |
| "scripts": { | |
| "heroku-postbuild": "webpack" | |
| }, | |
| "repository": { | |
| "type": "git", | |
| "url": "https://github.com/mariorcardoso/rails_webpack_npm_es6.git" |
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
| var path = require('path'); | |
| var webpack = require('webpack'); | |
| module.exports = { | |
| entry: [ | |
| 'babel-polyfill', | |
| './app-js/main', | |
| ], | |
| output: { | |
| path: __dirname + '/app/assets/javascripts', |
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
| import { Rectangle } from './rectangle' | |
| import { Square } from './square' | |
| import { Circle } from './circle' | |
| import { CanvasLibrary } from './canvas_library' | |
| $(document).ready(function() { | |
| const canvas = new CanvasLibrary(); | |
| const layer = canvas.get_layer(); | |
| const stage = canvas.get_stage(); |
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
| class Rectangle { | |
| constructor(height, width, color) { | |
| this.height = height | |
| this.width = width | |
| this.color = color | |
| } | |
| draw(layer, stage) { | |
| const rectangle = new Konva.Rect({ | |
| x: Math.random() * stage.getWidth(), |
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
| class Address | |
| attr_reader :city, :state | |
| def initialize(city, state) | |
| @city, @state = city, state | |
| end | |
| def ==(other_address) | |
| city == other_address.city && state == other_address.state | |
| end |
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
| class Event < ActiveRecord::Base | |
| def date_range | |
| DateRange.new(start_date, end_date) | |
| end | |
| def date_range=(date_range) | |
| self.start_date = date_range.start_date | |
| self.end_date = date_range.end_date | |
| end | |
| end |
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
| class DateRange | |
| attr_reader :start_date, :end_date | |
| def initialize(start_date, end_date) | |
| @start_date, @end_date = start_date, end_date | |
| end | |
| def include_date?(date) | |
| date >= start_date && date <= end_date | |
| end |
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
| class Person < ActiveRecord::Base | |
| def address | |
| Address.new(address_city, address_state) | |
| end | |
| def address=(address) | |
| self.address_city = address.city | |
| self.address_state = address.state | |
| end | |
| end |
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
| > gary = Person.create(name: "Gary") | |
| > gary.address_city = "Brooklyn" | |
| > gary.address_state = "NY" | |
| > gary.address | |
| => #<Address:0x007fcbfcce0188 @city="Brooklyn", @state="NY"> | |
| > gary.address = Address.new("Brooklyn", "NY") | |
| > gary.address | |
| => #<Address:0x007fcbfa3b2e78 @city="Brooklyn", @state="NY"> |
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
| class Grade | |
| include Comparable | |
| attr_reader :percentage | |
| def initialize(percentage) | |
| @percentage = percentage | |
| end | |
| def better_than?(other) | |
| self > other |
OlderNewer