Skip to content

Instantly share code, notes, and snippets.

sealed class Pet
data class Dog(val name: String, val breed: String, val tricks: Array<String>) : Pet()
data class Cat(val name: String, val breed: String) : Pet()
data class Bird(val name: String, val breed: String, val words: Array<String>) : Pet()
fun playWithPet(pet: Pet):String{
when(pet){
is Dog -> println("You played with a DOG!")
is Cat -> println("You played with a CAT!")
}
require 'rails_helper'
feature 'Creating weeks' do
scenario 'can create a week' do
visit '/weeks'
click_link 'New week'
fill_in 'Year', with: 2015
fill_in 'Month', with: 5
fill_in 'Week', with: 1
fill_in 'Start date', with: '5/4/15'
require 'rails_helper'
describe Week do
# it 'has a valid factory' do
# expect(create(:week)).to be_valid
# end
it 'is a Week' do
week = Week.new({year: 2015, month: 5, week: 1, start_date: Date.new(2015,5,4)})
expect(week).to be_valid
class Week < ActiveRecord::Base
has_many :pitch_rotation_weeks, join_table: :pitch_rotation_weeks_weeks
validates :year, presence: true
validates :month, presence: true
validates :week, presence: true
validates :start_date, presence: true
validates :week, uniqueness: {scope: [:year, :month], message: 'Year, month and week must be unique'}
validates :start_date, uniqueness: true
git commit -m 'Initial commit'
[master (root-commit) 2b28a64] Initial commit
6 files changed, 100 insertions(+)
create mode 100644 .rubocop.yml
create mode 100644 .ruby-gemset
create mode 100644 .ruby-version
create mode 100644 Gemfile
create mode 100644 Gemfile.lock
create mode 100644 Guardfile
git add .rubocop.yml .ruby-gemset .ruby-version Guardfile Gem*
git status
On branch master
Initial commit
Changes to be committed:
(use "git rm --cached <file>..." to unstage)
new file: .rubocop.yml
@piperniehaus
piperniehaus / gist:e4491324653cc7e82163
Created February 13, 2015 06:35
Git init, git status
ex-piper:git_warmup7 piper$ git init
Initialized empty Git repository in /Users/piper/workspace/davinci_coders_t1_2015/practice/git_warmup7/.git/
ex-piper:git_warmup7 piper$ git status
On branch master
Initial commit
Untracked files:
(use "git add <file>..." to include in what will be committed)
@piperniehaus
piperniehaus / gist:ec6620761c3b62e54623
Created February 13, 2015 06:16
Class superclass
Class.superclass
=> Module
GoldenRetriever.superclass
=> Dog
Dog.superclass
=> Object
class Dog
end
class GoldenRetriever < Dog
end
cimarron = GoldenRetriever.new
cimarron.class
=> GoldenRetriever