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
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!") | |
} |
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
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' |
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
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 |
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 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 |
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
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 |
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
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 |
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
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) |
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.superclass | |
=> Module |
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
GoldenRetriever.superclass | |
=> Dog | |
Dog.superclass | |
=> Object |
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 Dog | |
end | |
class GoldenRetriever < Dog | |
end | |
cimarron = GoldenRetriever.new | |
cimarron.class | |
=> GoldenRetriever |
NewerOlder