Slide 1

Slide 1 text

TVDDFTTJPO A Refactoring Story in Ruby Katrina Owen @kytrinyx http://exercism.io

Slide 2

Slide 2 text

I know an old lady who swallowed a . fly

Slide 3

Slide 3 text

I know an old lady who swallowed a . spider She swallowed the spider to catch the fly.

Slide 4

Slide 4 text

I know an old lady who swallowed a . bird She swallowed the bird to catch the spider. She swallowed the spider to catch the fly.

Slide 5

Slide 5 text

I know an old lady who swallowed a . cat She swallowed the cat to catch the bird. She swallowed the bird to catch the spider. She swallowed the spider to catch the fly.

Slide 6

Slide 6 text

I know an old lady who swallowed a . dog She swallowed the dog to catch the cat. She swallowed the cat to catch the bird. She swallowed the bird to catch the spider. She swallowed the spider to catch the fly.

Slide 7

Slide 7 text

I know an old lady who swallowed a . goat She swallowed the goat to catch the dog. She swallowed the dog to catch the cat. She swallowed the cat to catch the bird. She swallowed the bird to catch the spider. She swallowed the spider to catch the fly.

Slide 8

Slide 8 text

I know an old lady who swallowed a . cow She swallowed the cow to catch the goat. She swallowed the goat to catch the dog. She swallowed the dog to catch the cat. She swallowed the cat to catch the bird. She swallowed the bird to catch the spider. She swallowed the spider to catch the fly.

Slide 9

Slide 9 text

I know an old lady who swallowed a . horse

Slide 10

Slide 10 text

EFBE PGDPVSTF 4IFT

Slide 11

Slide 11 text

/ %@. @# @@@@( (@. ,@@@@@@@@, ,@% #@@@@@@@@@@@ .@& (@@@@@@@@@@@@@% @@( *@@@@@@@@@@@@@@@ (@@/ ,@@@@@@@@@@@@@@@@@, @/ @@@, %@@@@@@@@@@@@@@@@@@/ &@( &@@@ @@@@@@@@@@@@@@@@@@@@# &@/ @@@@. @@@@@@@@@@@@@@@@@@@@@/ &@# ,@@@( /@@@@@@@@@@@@@@@@@@@@@, %@& (@@, @@@. #@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ &@@. @@/ /@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@&/ &@@% /@@, %@@@@@@@@@@@@@@@@@@@@@@@@@/ %@@@. %@@* .@@@@@@@@@@@@@@@@@@@@@@@@@@@ %@@@/ @@@, &@@@@@@@@@@@@@@@@@@@@@@@@@@@& ./(%##////#. ,@@@@@@,,,.,.,.... ,@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@& *&@@@@@@@@@@@@@@@@@#. @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@# .&@@@@@& @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@/ /@@@@@&@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@# /@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@# ,,. #@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@* %@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@&(*. (%%%&@&&@@@@ (@@@* /@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@* &@@@@@, . (@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@& ,@@@@* *@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@( *@@@& @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@/ #, &@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@. ,%@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@&, /@@#&@@@@@@@& ,#@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@% *@@@@@@@@@@@@@ @@@@ ,@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@( .(@@@@@@@@% .@@@& (@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ ,@@@% &@@@@/,(#@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@. (@@@ #@@@@# .*,(@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@/ (@@@ @@@@ .,(#%&&@@@@@@@@@@@@@@@@@, *@@@% .@@@, .,*(##(*, ,@@@@@@/ @@@(. .@@@@( /@@@@@@&%((/, *@@@@ .*#&@@@@@@/ .@@@& ,@@&, *@@( (@@@. (@& *&% /@# /@. *@. %*

Slide 12

Slide 12 text

What a hog, to swallow a dog! She swallowed the dog to catch the She swallowed the cat to catch the She swallowed the bird to catch th She swallowed the spider to catch I don't know why she swallowed the I know an old lady who swallowed a Just opened her throat and swallow

Slide 13

Slide 13 text

<<-SONG I know an old lady who swallowed a fly. # ... She's dead, of course! SONG

Slide 14

Slide 14 text

def lyrics <<-SONG I know an old lady who swallowed a fly. # ... She's dead, of course! SONG end

Slide 15

Slide 15 text

class Song def lyrics <<-SONG I know an old lady who swallowed a fly. # ... She's dead, of course! SONG end end

Slide 16

Slide 16 text

JOUIF CFHJOOJOH

Slide 17

Slide 17 text

OPQF

Slide 18

Slide 18 text

BOETPJU CFHJOT

Slide 19

Slide 19 text

OPQF

Slide 20

Slide 20 text

class SongTest < Minitest::Test def test_lyrics <<-SONG I know an old lady who swallowed a fly. # ... She's dead, of course! SONG end end

Slide 21

Slide 21 text

class SongTest < Minitest::Test def test_lyrics expected = <<-SONG I know an old lady who swallowed a fly. # ... She's dead, of course! SONG assert_equal expected, Song.new.song end end

Slide 22

Slide 22 text

PODFVQPOB UJNF

Slide 23

Slide 23 text

OPQF

Slide 24

Slide 24 text

SFGBDUPS

Slide 25

Slide 25 text

It wriggled and jiggled and tickled inside her. She swallowed the spider to catch the fly. I don't know why she swallowed the fly. Perhaps she'll I know an old lady who swallowed a bird. How absurd to swallow a bird! She swallowed the bird to catch the spider that wriggle She swallowed the spider to catch the fly. I don't know why she swallowed the fly. Perhaps she'll I know an old lady who swallowed a cat. Imagine that, to swallow a cat! She swallowed the cat to catch the bird. She swallowed the bird to catch the spider that wriggle She swallowed the spider to catch the fly. I don't know why she swallowed the fly. Perhaps she'll

Slide 26

Slide 26 text

EVQMJDBUJPO

Slide 27

Slide 27 text

# ... I know an old lady who swallowed a fly. # ... I know an old lady who swallowed a spider. # ... I know an old lady who swallowed a bird. # ... I know an old lady who swallowed a cat. # ... I know an old lady who swallowed a dog. # ... I know an old lady who swallowed a goat. # ... I know an old lady who swallowed a cow. # ... I know an old lady who swallowed a horse. # ...

Slide 28

Slide 28 text

# ... She swallowed the dog to catch the cat. She swallowed the cat to catch the bird. She swallowed the bird to catch the spider that wriggled and She swallowed the spider to catch the fly. # ... She swallowed the goat to catch the dog. She swallowed the dog to catch the cat. She swallowed the cat to catch the bird. She swallowed the bird to catch the spider that wriggled and She swallowed the spider to catch the fly. # ... She swallowed the cow to catch the goat. She swallowed the goat to catch the dog. She swallowed the dog to catch the cat. She swallowed the cat to catch the bird. She swallowed the bird to catch the spider that wriggled and

Slide 29

Slide 29 text

I know an old lady who swallowed a dog. What a hog, to swallow a dog! She swallowed the dog to catch the cat. She swallowed the cat to catch the bird. She swallowed the bird to catch the spider that wriggled and She swallowed the spider to catch the fly. I don't know why she swallowed the fly. Perhaps she'll die. I know an old lady who swallowed a goat. Just opened her throat and swallowed a goat! She swallowed the goat to catch the dog. She swallowed the dog to catch the cat. She swallowed the cat to catch the bird. She swallowed the bird to catch the spider that wriggled and She swallowed the spider to catch the fly. I don't know why she swallowed the fly. Perhaps she'll die.

Slide 30

Slide 30 text

<<-SONG I know an old lady who swallowed a fly. I don't know why she swallowed the fly. Perhaps she'll die. I know an old lady who swallowed a spider. It wriggled and jiggled and tickled inside her. She swallowed the spider to catch the fly. I don't know why she swallowed the fly. Perhaps she'll die. I know an old lady who swallowed a bird. How absurd to swallow a bird! She swallowed the bird to catch the spider that wriggled and jiggled and tickled inside her. She swallowed the spider to catch the fly. I don't know why she swallowed the fly. Perhaps she'll die. I know an old lady who swallowed a cat. Imagine that, to swallow a cat! She swallowed the cat to catch the bird. She swallowed the bird to catch the spider that wriggled and jiggled and tickled inside her. She swallowed the spider to catch the fly. I don't know why she swallowed the fly. Perhaps she'll die. I know an old lady who swallowed a dog. What a hog, to swallow a dog! She swallowed the dog to catch the cat. She swallowed the cat to catch the bird. She swallowed the bird to catch the spider that wriggled and jiggled and tickled inside her. She swallowed the spider to catch the fly. I don't know why she swallowed the fly. Perhaps she'll die. I know an old lady who swallowed a goat. Just opened her throat and swallowed a goat! She swallowed the goat to catch the dog. She swallowed the dog to catch the cat. She swallowed the cat to catch the bird. She swallowed the bird to catch the spider that wriggled and jiggled and tickled inside her. She swallowed the spider to catch the fly. I don't know why she swallowed the fly. Perhaps she'll die. I know an old lady who swallowed a cow. I don't know how she swallowed a cow! She swallowed the cow to catch the goat. She swallowed the goat to catch the dog. She swallowed the dog to catch the cat. She swallowed the cat to catch the bird. She swallowed the bird to catch the spider that wriggled and jiggled and tickled inside her. She swallowed the spider to catch the fly. I don't know why she swallowed the fly. Perhaps she'll die. I know an old lady who swallowed a horse. She's dead, of course! SONG

Slide 31

Slide 31 text

JOEJSFDUJPO

Slide 32

Slide 32 text

case i when 1 "I know an old lady who swallowed a fly.\n" + "I don't know why she swallowed the fly. Perhaps...\n" when 2 "I know an old lady who swallowed a spider.\n" + "It wriggled and jiggled and tickled inside her.\n" + "She swallowed the spider to catch the fly.\n" + "I don't know why she swallowed the fly. Perhaps...\n" when 3 "I know an old lady who swallowed a bird.\n" + "How absurd to swallow a bird!\n" + "She swallowed the bird to catch the spider that..." + "She swallowed the spider to catch the fly.\n" + "I don't know why she swallowed the fly. Perhaps...\n" when 4

Slide 33

Slide 33 text

(1..8).map {|i| case i when 1 # ... when n # ... end }.join("\n")

Slide 34

Slide 34 text

def lyrics (1..8).map {|i| case i when 1 # ... when n # ... end }.join("\n") end

Slide 35

Slide 35 text

def song (1..8).map {|i| case i when 1 # ... when n # ... end }.join("\n") end

Slide 36

Slide 36 text

def song (1..8).map {|i| verse(i) }.join("\n") end

Slide 37

Slide 37 text

private def verse(i) case i when 1 # ... when n # ... end end

Slide 38

Slide 38 text

case i when 1 "I know an old lady who swallowed a fly.\n" + "I don't know why she swallowed the fly. Perhaps she'l when 2 "I know an old lady who swallowed a spider.\n" + "It wriggled and jiggled and tickled inside her.\n" + "She swallowed the spider to catch the fly.\n" + "I don't know why she swallowed the fly. Perhaps she'l when 3 "I know an old lady who swallowed a bird.\n" + "How absurd to swallow a bird!\n" + "She swallowed the bird to catch the spider that wrigg "She swallowed the spider to catch the fly.\n" + "I don't know why she swallowed the fly. Perhaps she'l

Slide 39

Slide 39 text

case i when 1 "I know an old lady who swallowed a fly.\n" + "I don't know why she swallowed the fly. Perhaps she'l when 2 "I know an old lady who swallowed a spider.\n" + "It wriggled and jiggled and tickled inside her.\n" + "She swallowed the spider to catch the fly.\n" + "I don't know why she swallowed the fly. Perhaps she'l when 3 "I know an old lady who swallowed a bird.\n" + "How absurd to swallow a bird!\n" + "She swallowed the bird to catch the spider that wrigg "She swallowed the spider to catch the fly.\n" + "I don't know why she swallowed the fly. Perhaps she'l

Slide 40

Slide 40 text

case i when 1 "I know an old lady who swallowed a fly.\n" + "I don't know why she swallowed the fly. Perhaps she'l when 2 "I know an old lady who swallowed a spider.\n" + "It wriggled and jiggled and tickled inside her.\n" + "She swallowed the spider to catch the fly.\n" + "I don't know why she swallowed the fly. Perhaps she'l when 3 "I know an old lady who swallowed a bird.\n" + "How absurd to swallow a bird!\n" + "She swallowed the bird to catch the spider that wrigg "She swallowed the spider to catch the fly.\n" + "I don't know why she swallowed the fly. Perhaps she'l

Slide 41

Slide 41 text

case i when 1 "I know an old lady who swallowed a fly.\n" + "I don't know why she swallowed the fly. Perhaps she'l when 2 "I know an old lady who swallowed a spider.\n" + "It wriggled and jiggled and tickled inside her.\n" + "She swallowed the spider to catch the fly.\n" + "I don't know why she swallowed the fly. Perhaps she'l when 3 "I know an old lady who swallowed a bird.\n" + "How absurd to swallow a bird!\n" + "She swallowed the bird to catch the spider that wrigg "She swallowed the spider to catch the fly.\n" + "I don't know why she swallowed the fly. Perhaps she'l

Slide 42

Slide 42 text

UFNQMBUFEBUB

Slide 43

Slide 43 text

"template vs data"

Slide 44

Slide 44 text

"template vs %s" % "data"

Slide 45

Slide 45 text

"template vs %s" % "data"

Slide 46

Slide 46 text

"template vs %s" % "data"

Slide 47

Slide 47 text

"template vs %s" % "data"

Slide 48

Slide 48 text

"%s vs template" % "data"

Slide 49

Slide 49 text

"template vs %s" % "data"

Slide 50

Slide 50 text

"template vs %s" % "data"

Slide 51

Slide 51 text

case i when 1 "I know an old lady who swallowed a fly.\n" when 2 "I know an old lady who swallowed a spider.\n" when 3 "I know an old lady who swallowed a bird.\n" when 4 "I know an old lady who swallowed a cat.\n" when 5 "I know an old lady who swallowed a dog.\n" when 6 "I know an old lady who swallowed a goat.\n" when 7 "I know an old lady who swallowed a cow.\n" when 8 "I know an old lady who swallowed a horse.\n" end

Slide 52

Slide 52 text

case i when 1 "I know an old lady who swallowed a %s.\n" % "fly" when 2 "I know an old lady who swallowed a %s.\n" % "spider" when 3 "I know an old lady who swallowed a %s.\n" % "bird" when 4 "I know an old lady who swallowed a %s.\n" % "cat" when 5 "I know an old lady who swallowed a %s.\n" % "dog" when 6 "I know an old lady who swallowed a %s.\n" % "goat" when 7 "I know an old lady who swallowed a %s.\n" % "cow" when 8 "I know an old lady who swallowed a %s.\n" % "horse" end

Slide 53

Slide 53 text

case i when 1 "I know an old lady who swallowed a %s.\n" % "fly" when 2 "I know an old lady who swallowed a %s.\n" % "spider" when 3 "I know an old lady who swallowed a %s.\n" % "bird" when 4 "I know an old lady who swallowed a %s.\n" % "cat" when 5 "I know an old lady who swallowed a %s.\n" % "dog" when 6 "I know an old lady who swallowed a %s.\n" % "goat" when 7 "I know an old lady who swallowed a %s.\n" % "cow" when 8 "I know an old lady who swallowed a %s.\n" % "horse" end

Slide 54

Slide 54 text

"She swallowed the bird to catch the spider that wrig "She swallowed the spider to catch the fly.\n" + when 6 "She swallowed the goat to catch the dog.\n" + "She swallowed the dog to catch the cat.\n" + "She swallowed the cat to catch the bird.\n" + "She swallowed the bird to catch the spider that wrig "She swallowed the spider to catch the fly.\n" + when 7 "She swallowed the cow to catch the goat.\n" + "She swallowed the goat to catch the dog.\n" + "She swallowed the dog to catch the cat.\n" + "She swallowed the cat to catch the bird.\n" + "She swallowed the bird to catch the spider that wrig "She swallowed the spider to catch the fly.\n" + when 8

Slide 55

Slide 55 text

"She swallowed the %s to catch the %s.\n" % ["bird", "She swallowed the %s to catch the %s.\n" % ["spider when 6 "She swallowed the %s to catch the %s.\n" % ["goat", "She swallowed the %s to catch the %s.\n" % ["dog", "She swallowed the %s to catch the %s.\n" % ["cat", "She swallowed the %s to catch the %s.\n" % ["bird", "She swallowed the %s to catch the %s.\n" % ["spider when 7 "She swallowed the %s to catch the %s.\n" % ["goat", "She swallowed the %s to catch the %s.\n" % ["dog", "She swallowed the %s to catch the %s.\n" % ["cat", "She swallowed the %s to catch the %s.\n" % ["bird", "She swallowed the %s to catch the %s.\n" % ["spider "She swallowed the %s to catch the %s.\n" % ["spider when 8

Slide 56

Slide 56 text

"I know an old lady who swallowed a %s.\n" % "%s\n" % "She swallowed the %s to catch the %s.\n" % "She swallowed the %s to catch the %s.\n" % "She swallowed the %s to catch the %s.\n" % "She swallowed the %s to catch the %s.\n" % "She swallowed the %s to catch the %s.\n" % "She swallowed the %s to catch the %s.\n" % "%s\n" %

Slide 57

Slide 57 text

% "cow" + % "I don't know how she swallowed a cow!" + % ["cow", "goat"] + % ["goat", "dog"] + % ["dog", "cat"] + % ["cat", "bird"] + % ["bird", "spider that wriggled and..."] + % ["spider", "fly"] + % "I don't know why she swallowed the fly...

Slide 58

Slide 58 text

<<-SONG I know an old lady who swallowed a fly. I don't know why she swallowed the fly. Perhaps she'll die. I know an old lady who swallowed a spider. It wriggled and jiggled and tickled inside her. She swallowed the spider to catch the fly. I don't know why she swallowed the fly. Perhaps she'll die. I know an old lady who swallowed a bird. How absurd to swallow a bird! She swallowed the bird to catch the spider that wriggled and jiggled and tickled inside her. She swallowed the spider to catch the fly. I don't know why she swallowed the fly. Perhaps she'll die. I know an old lady who swallowed a cat. Imagine that, to swallow a cat! She swallowed the cat to catch the bird. She swallowed the bird to catch the spider that wriggled and jiggled and tickled inside her. She swallowed the spider to catch the fly. I don't know why she swallowed the fly. Perhaps she'll die. I know an old lady who swallowed a dog. What a hog, to swallow a dog! She swallowed the dog to catch the cat. She swallowed the cat to catch the bird. She swallowed the bird to catch the spider that wriggled and jiggled and tickled inside her. She swallowed the spider to catch the fly. I don't know why she swallowed the fly. Perhaps she'll die. I know an old lady who swallowed a goat. Just opened her throat and swallowed a goat! She swallowed the goat to catch the dog. She swallowed the dog to catch the cat. She swallowed the cat to catch the bird. She swallowed the bird to catch the spider that wriggled and jiggled and tickled inside her. She swallowed the spider to catch the fly. I don't know why she swallowed the fly. Perhaps she'll die. I know an old lady who swallowed a cow. I don't know how she swallowed a cow! She swallowed the cow to catch the goat. She swallowed the goat to catch the dog. She swallowed the dog to catch the cat. She swallowed the cat to catch the bird. She swallowed the bird to catch the spider that wriggled and jiggled and tickled inside her. She swallowed the spider to catch the fly. I don't know why she swallowed the fly. Perhaps she'll die. I know an old lady who swallowed a horse. She's dead, of course! SONG

Slide 59

Slide 59 text

case i when 1 "I know an old lady who swallowed a fly.\n" + "I don't know why she swallowed the fly. Perhaps she'll die.\n" when 2 "I know an old lady who swallowed a spider.\n" + "It wriggled and jiggled and tickled inside her.\n" + "She swallowed the spider to catch the fly.\n" + "I don't know why she swallowed the fly. Perhaps she'll die.\n" when 3 "I know an old lady who swallowed a bird.\n" + "How absurd to swallow a bird!\n" + "She swallowed the bird to catch the spider that wriggled and jiggled and tickled inside her.\n" + "She swallowed the spider to catch the fly.\n" + "I don't know why she swallowed the fly. Perhaps she'll die.\n" when 4 "I know an old lady who swallowed a cat.\n" + "Imagine that, to swallow a cat!\n" + "She swallowed the cat to catch the bird.\n" + "She swallowed the bird to catch the spider that wriggled and jiggled and tickled inside her.\n" + "She swallowed the spider to catch the fly.\n" + "I don't know why she swallowed the fly. Perhaps she'll die.\n" when 5 "I know an old lady who swallowed a dog.\n" + "What a hog, to swallow a dog!\n" + "She swallowed the dog to catch the cat.\n" + "She swallowed the cat to catch the bird.\n" + "She swallowed the bird to catch the spider that wriggled and jiggled and tickled inside her.\n" + "She swallowed the spider to catch the fly.\n" + "I don't know why she swallowed the fly. Perhaps she'll die.\n" when 6 "I know an old lady who swallowed a goat.\n" + "Just opened her throat and swallowed a goat!\n" + "She swallowed the goat to catch the dog.\n" + "She swallowed the dog to catch the cat.\n" + "She swallowed the cat to catch the bird.\n" + "She swallowed the bird to catch the spider that wriggled and jiggled and tickled inside her.\n" + "She swallowed the spider to catch the fly.\n" + "I don't know why she swallowed the fly. Perhaps she'll die.\n" when 7 "I know an old lady who swallowed a cow.\n" + "I don't know how she swallowed a cow!\n" + "She swallowed the cow to catch the goat.\n" + "She swallowed the goat to catch the dog.\n" + "She swallowed the dog to catch the cat.\n" + "She swallowed the cat to catch the bird.\n" + "She swallowed the bird to catch the spider that wriggled and jiggled and tickled inside her.\n" + "She swallowed the spider to catch the fly.\n" + "I don't know why she swallowed the fly. Perhaps she'll die.\n" when 8 "I know an old lady who swallowed a horse.\n" + "She's dead, of course!\n" end

Slide 60

Slide 60 text

case i when 1 "I know an old lady who swallowed a %s.\n" % "fly" + "%s\n" % "I don't know why she swallowed the fly. Perhaps she'll die." when 2 "I know an old lady who swallowed a %s.\n" % "spider" + "%s\n" % "It wriggled and jiggled and tickled inside her." + "She swallowed the %s to catch the %s.\n" % ["spider", "fly"] + "%s\n" % "I don't know why she swallowed the fly. Perhaps she'll die." when 3 "I know an old lady who swallowed a %s.\n" % "bird" + "%s\n" % "How absurd to swallow a bird!" + "She swallowed the %s to catch the %s.\n" % ["bird", "spider that wriggled and jiggled and tickled inside her"] + "She swallowed the %s to catch the %s.\n" % ["spider", "fly"] + "%s\n" % "I don't know why she swallowed the fly. Perhaps she'll die." when 4 "I know an old lady who swallowed a %s.\n" % "cat"+ "%s\n" % "Imagine that, to swallow a cat!" + "She swallowed the %s to catch the %s.\n" % ["cat", "bird"] + "She swallowed the %s to catch the %s.\n" % ["bird", "spider that wriggled and jiggled and tickled inside her"] + "She swallowed the %s to catch the %s.\n" % ["spider", "fly"] + "%s\n" % "I don't know why she swallowed the fly. Perhaps she'll die." when 5 "I know an old lady who swallowed a %s.\n" % "dog" + "%s\n" % "What a hog, to swallow a dog!" + "She swallowed the %s to catch the %s.\n" % ["dog", "cat"] + "She swallowed the %s to catch the %s.\n" % ["cat", "bird"] + "She swallowed the %s to catch the %s.\n" % ["bird", "spider that wriggled and jiggled and tickled inside her"] + "She swallowed the %s to catch the %s.\n" % ["spider", "fly"] + "%s\n" % "I don't know why she swallowed the fly. Perhaps she'll die." when 6 "I know an old lady who swallowed a %s.\n" % "goat" + "%s\n" % "Just opened her throat and swallowed a goat!" + "She swallowed the %s to catch the %s.\n" % ["goat", "dog"] + "She swallowed the %s to catch the %s.\n" % ["dog", "cat"] + "She swallowed the %s to catch the %s.\n" % ["cat", "bird"] + "She swallowed the %s to catch the %s.\n" % ["bird", "spider that wriggled and jiggled and tickled inside her"] + "She swallowed the %s to catch the %s.\n" % ["spider", "fly"] + "%s\n" % "I don't know why she swallowed the fly. Perhaps she'll die." when 7 "I know an old lady who swallowed a %s.\n" % "cow" + "%s\n" % "I don't know how she swallowed a cow!" + "She swallowed the %s to catch the %s.\n" % ["cow", "goat"] + "She swallowed the %s to catch the %s.\n" % ["goat", "dog"] + "She swallowed the %s to catch the %s.\n" % ["dog", "cat"] + "She swallowed the %s to catch the %s.\n" % ["cat", "bird"] + "She swallowed the %s to catch the %s.\n" % ["bird", "spider that wriggled and jiggled and tickled inside her"] + "She swallowed the %s to catch the %s.\n" % ["spider", "fly"] + "%s\n" % "I don't know why she swallowed the fly. Perhaps she'll die." when 8 "I know an old lady who swallowed a %s.\n" % "horse" + "%s\n" % "She's dead, of course!" end

Slide 61

Slide 61 text

No content

Slide 62

Slide 62 text

BMHPSJUIN

Slide 63

Slide 63 text

case i when 1 "I know an old lady who swallowed a %s.\n" % "%s\n" %

Slide 64

Slide 64 text

case i when 2 "I know an old lady who swallowed a %s.\n" % "%s\n" % "She swallowed the %s to catch the %s.\n" % "%s\n" %

Slide 65

Slide 65 text

case i when 3 "I know an old lady who swallowed a %s.\n" % "%s\n" % "She swallowed the %s to catch the %s.\n" % "She swallowed the %s to catch the %s.\n" % "%s\n" %

Slide 66

Slide 66 text

case i when 4 "I know an old lady who swallowed a %s.\n" % "%s\n" % "She swallowed the %s to catch the %s.\n" % "She swallowed the %s to catch the %s.\n" % "She swallowed the %s to catch the %s.\n" % "%s\n" %

Slide 67

Slide 67 text

case i when 5 "I know an old lady who swallowed a %s.\n" % "%s\n" % "She swallowed the %s to catch the %s.\n" % "She swallowed the %s to catch the %s.\n" % "She swallowed the %s to catch the %s.\n" % "She swallowed the %s to catch the %s.\n" % "%s\n" %

Slide 68

Slide 68 text

case i when 6 "I know an old lady who swallowed a %s.\n" % "%s\n" % "She swallowed the %s to catch the %s.\n" % "She swallowed the %s to catch the %s.\n" % "She swallowed the %s to catch the %s.\n" % "She swallowed the %s to catch the %s.\n" % "She swallowed the %s to catch the %s.\n" % "%s\n" %

Slide 69

Slide 69 text

case i when 7 "I know an old lady who swallowed a %s.\n" % "%s\n" % "She swallowed the %s to catch the %s.\n" % "She swallowed the %s to catch the %s.\n" % "She swallowed the %s to catch the %s.\n" % "She swallowed the %s to catch the %s.\n" % "She swallowed the %s to catch the %s.\n" % "She swallowed the %s to catch the %s.\n" % "%s\n" %

Slide 70

Slide 70 text

case i when 8 "I know an old lady who swallowed a %s.\n" % "%s\n" %

Slide 71

Slide 71 text

"She swallowed the %s to catch the %s"

Slide 72

Slide 72 text

"She swallowed the %s to catch the %s" * n

Slide 73

Slide 73 text

"She swallowed the %s to catch the %s" % [predator, prey]

Slide 74

Slide 74 text

"She swallowed the %s to catch the %s." % [ predator, prey, ]

Slide 75

Slide 75 text

def swallow(predator, prey) "She swallowed the %s to catch the %s." % [ predator, prey, ] end

Slide 76

Slide 76 text

def to_catch(predator, prey) "She swallowed the %s to catch the %s." % [ predator, prey, ] end

Slide 77

Slide 77 text

def blue "FF0000" end

Slide 78

Slide 78 text

"She swallowed the %s to catch the %s." % [ predator, prey, ]

Slide 79

Slide 79 text

def recurring_line(predator, prey) "She swallowed the %s to catch the %s." % [ predator, prey, ] end

Slide 80

Slide 80 text

def incremental_sentence(predator, prey) "She swallowed the %s to catch the %s." % [ predator, prey, ] end

Slide 81

Slide 81 text

def middle_phrase(predator, prey) "She swallowed the %s to catch the %s." % [ predator, prey, ] end

Slide 82

Slide 82 text

"She swallowed the %s to catch the %s." % [ predator, prey, ]

Slide 83

Slide 83 text

def reasoning(predator, prey) "She swallowed the %s to catch the %s." % [ predator, prey, ] end

Slide 84

Slide 84 text

def why(predator, prey) "She swallowed the %s to catch the %s." % [ predator, prey, ] end

Slide 85

Slide 85 text

def motivation(predator, prey) "She swallowed the %s to catch the %s." % [ predator, prey, ] end

Slide 86

Slide 86 text

["cow", "goat"] ["goat", "dog"] ["dog", "cat"] ["cat", "bird"] ["bird", "spider"] ["spider", "fly"]

Slide 87

Slide 87 text

["cow", "goat"] ["goat", "dog"] ["dog", "cat"] ["cat", "bird"] ["bird", "spider"] ["spider", "fly"]

Slide 88

Slide 88 text

["cow", "goat"] ["goat", "dog"] ["dog", "cat"] ["cat", "bird"] ["bird", "spider"] ["spider", "fly"]

Slide 89

Slide 89 text

["cow", "goat"] ["goat", "dog"] ["dog", "cat"] ["cat", "bird"] ["bird", "spider"] ["spider", "fly"]

Slide 90

Slide 90 text

["cow", "goat"] ["goat", "dog"] ["dog", "cat"] ["cat", "bird"] ["bird", "spider"] ["spider", "fly"]

Slide 91

Slide 91 text

["cow", "goat"] ["goat", "dog"] ["dog", "cat"] ["cat", "bird"] ["bird", "spider"] ["spider", "fly"]

Slide 92

Slide 92 text

["cow", "goat", "dog", ...]

Slide 93

Slide 93 text

[...].each_cons(2)

Slide 94

Slide 94 text

["cow", "goat", "dog", "cat", "bird", ...]

Slide 95

Slide 95 text

critters.each_cons(2).map {|pair| motivation(*pair) }

Slide 96

Slide 96 text

critters.each_cons(2).map {|pair| motivation(*pair) }

Slide 97

Slide 97 text

critters.each_cons(2).map {|pair| motivation(*pair) }.join("\n")

Slide 98

Slide 98 text

def sequence(critters) critters.each_cons(2).map {|pair| motivation(*pair) }.join("\n") end

Slide 99

Slide 99 text

def chain(critters) critters.each_cons(2).map {|pair| motivation(*pair) }.join("\n") end

Slide 100

Slide 100 text

food chain BIJFSBSDIJDBMTFSJFTPG PSHBOJTNTFBDIEFQFOEFOU POUIFOFYUBTBTPVSDFPG GPPE

Slide 101

Slide 101 text

def chain(critters) critters.each_cons(2).map {|pair| motivation(*pair) }.join("\n") end def motivation(predator, prey) "She swallowed the %s to catch the %s." % [ predator, prey, ] end

Slide 102

Slide 102 text

"She swallowed the cow to catch the goat.\n" + "She swallowed the goat to catch the dog.\n" + "She swallowed the dog to catch the cat.\n" + "She swallowed the cat to catch the bird.\n" + "She swallowed the bird to catch the spider.\n" + "She swallowed the spider to catch the fly.\n" +

Slide 103

Slide 103 text

def chain(critters) critters.each_cons(2).map {|pair| motivation(*pair) }.join("\n") end def motivation(predator, prey) "She swallowed the %s to catch the %s." % [ predator, prey, ] end

Slide 104

Slide 104 text

No content

Slide 105

Slide 105 text

BOPNBMZ

Slide 106

Slide 106 text

She swallowed the cow to catch the goat. She swallowed the goat to catch the dog. She swallowed the dog to catch the cat. She swallowed the cat to catch the bird. She swallowed the bird to catch the spider that wriggled and jiggled and tickled inside her. She swallowed the spider to catch the fly.

Slide 107

Slide 107 text

if prey == "spider" # ... else # ... end

Slide 108

Slide 108 text

EJGGFSFODF

Slide 109

Slide 109 text

if prey == "spider" "She swallowed [...] that wriggled [...]." else "She swallowed [...]." end

Slide 110

Slide 110 text

if prey == "spider" "She swallowed [...] that wriggled [...]." else "She swallowed [...]." end

Slide 111

Slide 111 text

if prey == "spider" "She swallowed [...] that wriggled [...]." else "She swallowed [...]." end

Slide 112

Slide 112 text

if prey == "spider" "She swallowed [...] that wriggled [...]." else "She swallowed [...]." end

Slide 113

Slide 113 text

if prey == "spider" " that wriggled [...]" else ??? end

Slide 114

Slide 114 text

if prey == "spider" " that wriggled [...]" end

Slide 115

Slide 115 text

TZNNFUSZ

Slide 116

Slide 116 text

if prey == "spider" " that wriggled..." else "" end

Slide 117

Slide 117 text

def distinctive_features if prey == "spider" " that wriggled..." else "" end end

Slide 118

Slide 118 text

def qualifier if prey == "spider" " that wriggled..." else "" end end

Slide 119

Slide 119 text

if prey == "spider" " that wriggled..." end

Slide 120

Slide 120 text

def spider_tag if prey == "spider" " that wriggled..." end end

Slide 121

Slide 121 text

def qualifier if prey == "spider" " that wriggled..." else "" end end

Slide 122

Slide 122 text

def qualifier(prey) if prey == "spider" " that wriggled..." else "" end end

Slide 123

Slide 123 text

def qualifier(critter) if critter == "spider" " that wriggled..." else "" end end

Slide 124

Slide 124 text

qualifier(critter)

Slide 125

Slide 125 text

critter.qualifier

Slide 126

Slide 126 text

class Critter < Struct.new(:name, :qualifier) end

Slide 127

Slide 127 text

class Song DATA = [ ] end

Slide 128

Slide 128 text

class Song DATA = [ ["horse"], ["cow"], ["goat"], ["dog"], ["cat"], ["bird"], ["spider", "that wriggled ..."], ["fly"], ] end

Slide 129

Slide 129 text

class Song DATA = [...] attr_reader :critters def initialize @critters = DATA.map {|row| Critter.new(*row) } end end

Slide 130

Slide 130 text

def motivation(predator, prey) # ... end

Slide 131

Slide 131 text

def motivation(predator, prey) "She swallowed the %s to catch the %s." % [ predator.name, [ prey.name, prey.qualifier, ].compact.join(" "), ] end

Slide 132

Slide 132 text

class Critter < Struct.new(:name, :qualifier) end class Song # ... def motivation(predator, prey) "She swallowed the %s to catch the %s." % [ predator.name, [ prey.name, prey.qualifier, ].compact.join(" "), ] end # ... end

Slide 133

Slide 133 text

def motivation(predator, prey) "She swallowed the %s to catch the %s." % [ predator.name, [ prey.name, prey.qualifier, ].compact.join(" "), ] end

Slide 134

Slide 134 text

def motivation(predator, prey) "She swallowed the %s to catch the %s." % [ predator, prey, ] end

Slide 135

Slide 135 text

def motivation(predator, prey) "She swallowed the %s to catch the %s." % [ predator.name, [ prey.name, prey.qualifier, ].compact.join(" "), ] end

Slide 136

Slide 136 text

def motivation(predator, prey) "She swallowed the %s to catch the %s." % [ predator.name, [ prey.name, prey.qualifier, ].compact.join(" "), ] end TMI

Slide 137

Slide 137 text

[ critter.name, critter.qualifier ].compact.join(" ")

Slide 138

Slide 138 text

def epithet(critter) [ critter.name, critter.qualifier ].compact.join(" ") end

Slide 139

Slide 139 text

def epithet(critter) [ critter.name, critter.qualifier ].compact.join(" ") end

Slide 140

Slide 140 text

class Critter < Struct.new(:name, :qualifier) def epithet [ name, qualifier ].compact.join(" ") end end

Slide 141

Slide 141 text

No content

Slide 142

Slide 142 text

"%s\n" % "I don't know why she swallowed the fly. when 4 "I know an old lady who swallowed a %s.\n" % "cat"+ "%s\n" % "Imagine that, to swallow a cat!" + "She swallowed the %s to catch the %s.\n" % ["cat", "bird"] + "She swallowed the %s to catch the %s.\n" % ["bird", "spider that wriggled and jiggle "She swallowed the %s to catch the %s.\n" % ["spider", "fly"] + "%s\n" % "I don't know why she swallowed the fly. when 5 "I know an old lady who swallowed a %s.\n" % "dog" + "%s\n" % "What a hog, to swallow a dog!" + "She swallowed the %s to catch the %s.\n" % ["dog", "cat"] + "She swallowed the %s to catch the %s.\n" % ["cat", "bird"] + "She swallowed the %s to catch the %s.\n" % ["bird", "spider that wriggled and jiggle "She swallowed the %s to catch the %s.\n" % ["spider", "fly"] + "%s\n" % "I don't know why she swallowed the fly. when 6 "I know an old lady who swallowed a %s.\n" % "goat" + "%s\n" % "Just opened her throat and swallowed a g "She swallowed the %s to catch the %s.\n" % ["goat", "dog"] + "She swallowed the %s to catch the %s.\n" % ["dog", "cat"] + "She swallowed the %s to catch the %s.\n" % ["cat", "bird"] + "She swallowed the %s to catch the %s.\n" % ["bird", "spider that wriggled and jiggle

Slide 143

Slide 143 text

"%s\n" % "I don't know why she swallowed the fly. when 4 "I know an old lady who swallowed a %s.\n" % "cat"+ "%s\n" % "Imagine that, to swallow a cat!" + "She swallowed the %s to catch the %s.\n" % ["cat", "bird"] + "She swallowed the %s to catch the %s.\n" % ["bird", "spider that wriggled and jiggle "She swallowed the %s to catch the %s.\n" % ["spider", "fly"] + "%s\n" % "I don't know why she swallowed the fly. when 5 "I know an old lady who swallowed a %s.\n" % "dog" + "%s\n" % "What a hog, to swallow a dog!" + "She swallowed the %s to catch the %s.\n" % ["dog", "cat"] + "She swallowed the %s to catch the %s.\n" % ["cat", "bird"] + "She swallowed the %s to catch the %s.\n" % ["bird", "spider that wriggled and jiggle "She swallowed the %s to catch the %s.\n" % ["spider", "fly"] + "%s\n" % "I don't know why she swallowed the fly. when 6 "I know an old lady who swallowed a %s.\n" % "goat" + "%s\n" % "Just opened her throat and swallowed a g "She swallowed the %s to catch the %s.\n" % ["goat", "dog"] + "She swallowed the %s to catch the %s.\n" % ["dog", "cat"] + "She swallowed the %s to catch the %s.\n" % ["cat", "bird"] + "She swallowed the %s to catch the %s.\n" % ["bird", "spider that wriggled and jiggle

Slide 144

Slide 144 text

"%s\n" % "I don't know why she swallowed the fly. when 4 "I know an old lady who swallowed a %s.\n" % "cat"+ "%s\n" % "Imagine that, to swallow a cat!" + "%s\n" % chain(4) + "%s\n" % "I don't know why she swallowed the fly. when 5 "I know an old lady who swallowed a %s.\n" % "dog" + "%s\n" % "What a hog, to swallow a dog!" + "%s\n" % chain(5) + "%s\n" % "I don't know why she swallowed the fly. when 6 "I know an old lady who swallowed a %s.\n" % "goat" + "%s\n" % "Just opened her throat and swallowed a g "%s\n" % chain(6) + "%s\n" % "I don't know why she swallowed the fly. when 7 "I know an old lady who swallowed a %s.\n" % "cow" + "%s\n" % "I don't know how she swallowed a cow!" + "%s\n" % chain(7) + "%s\n" % "I don't know why she swallowed the fly. when 8 "I know an old lady who swallowed a %s.\n" % "horse" +

Slide 145

Slide 145 text

# Running: . 1 assertions, 0 failures, 0 errors, 0 skips

Slide 146

Slide 146 text

case i when 1 "I know an old lady who swallowed a %s.\n" % "fly" + "%s\n" % "I don't know why she swallowed the fly. Perhaps she'll die." when 2 "I know an old lady who swallowed a %s.\n" % "spider" + "%s\n" % "It wriggled and jiggled and tickled inside her." + "She swallowed the %s to catch the %s.\n" % ["spider", "fly"] + "%s\n" % "I don't know why she swallowed the fly. Perhaps she'll die." when 3 "I know an old lady who swallowed a %s.\n" % "bird" + "%s\n" % "How absurd to swallow a bird!" + "She swallowed the %s to catch the %s.\n" % ["bird", "spider that wriggled and jiggled and tickled inside her"] + "She swallowed the %s to catch the %s.\n" % ["spider", "fly"] + "%s\n" % "I don't know why she swallowed the fly. Perhaps she'll die." when 4 "I know an old lady who swallowed a %s.\n" % "cat"+ "%s\n" % "Imagine that, to swallow a cat!" + "She swallowed the %s to catch the %s.\n" % ["cat", "bird"] + "She swallowed the %s to catch the %s.\n" % ["bird", "spider that wriggled and jiggled and tickled inside her"] + "She swallowed the %s to catch the %s.\n" % ["spider", "fly"] + "%s\n" % "I don't know why she swallowed the fly. Perhaps she'll die." when 5 "I know an old lady who swallowed a %s.\n" % "dog" + "%s\n" % "What a hog, to swallow a dog!" + "She swallowed the %s to catch the %s.\n" % ["dog", "cat"] + "She swallowed the %s to catch the %s.\n" % ["cat", "bird"] + "She swallowed the %s to catch the %s.\n" % ["bird", "spider that wriggled and jiggled and tickled inside her"] + "She swallowed the %s to catch the %s.\n" % ["spider", "fly"] + "%s\n" % "I don't know why she swallowed the fly. Perhaps she'll die." when 6 "I know an old lady who swallowed a %s.\n" % "goat" + "%s\n" % "Just opened her throat and swallowed a goat!" + "She swallowed the %s to catch the %s.\n" % ["goat", "dog"] + "She swallowed the %s to catch the %s.\n" % ["dog", "cat"] + "She swallowed the %s to catch the %s.\n" % ["cat", "bird"] + "She swallowed the %s to catch the %s.\n" % ["bird", "spider that wriggled and jiggled and tickled inside her"] + "She swallowed the %s to catch the %s.\n" % ["spider", "fly"] + "%s\n" % "I don't know why she swallowed the fly. Perhaps she'll die." when 7 "I know an old lady who swallowed a %s.\n" % "cow" + "%s\n" % "I don't know how she swallowed a cow!" + "She swallowed the %s to catch the %s.\n" % ["cow", "goat"] + "She swallowed the %s to catch the %s.\n" % ["goat", "dog"] + "She swallowed the %s to catch the %s.\n" % ["dog", "cat"] + "She swallowed the %s to catch the %s.\n" % ["cat", "bird"] + "She swallowed the %s to catch the %s.\n" % ["bird", "spider that wriggled and jiggled and tickled inside her"] + "She swallowed the %s to catch the %s.\n" % ["spider", "fly"] + "%s\n" % "I don't know why she swallowed the fly. Perhaps she'll die." when 8 "I know an old lady who swallowed a %s.\n" % "horse" + "%s\n" % "She's dead, of course!" end

Slide 147

Slide 147 text

case i when 1 "I know an old lady who swallowed a %s.\n" % "fly" + "%s\n" % "I don't know why she swallowed the fly. Perhaps she'll die." when 2 "I know an old lady who swallowed a %s.\n" % "spider" + "%s\n" % "It wriggled and jiggled and tickled inside her." + "%s\n" % chain(2) + "%s\n" % "I don't know why she swallowed the fly. Perhaps she'll die." when 3 "I know an old lady who swallowed a %s.\n" % "bird" + "%s\n" % "How absurd to swallow a bird!" + "%s\n" % chain(3) + "%s\n" % "I don't know why she swallowed the fly. Perhaps she'll die." when 4 "I know an old lady who swallowed a %s.\n" % "cat"+ "%s\n" % "Imagine that, to swallow a cat!" + "%s\n" % chain(4) + "%s\n" % "I don't know why she swallowed the fly. Perhaps she'll die." when 5 "I know an old lady who swallowed a %s.\n" % "dog" + "%s\n" % "What a hog, to swallow a dog!" + "%s\n" % chain(5) + "%s\n" % "I don't know why she swallowed the fly. Perhaps she'll die." when 6 "I know an old lady who swallowed a %s.\n" % "goat" + "%s\n" % "Just opened her throat and swallowed a goat!" + "%s\n" % chain(6) + "%s\n" % "I don't know why she swallowed the fly. Perhaps she'll die." when 7 "I know an old lady who swallowed a %s.\n" % "cow" + "%s\n" % "I don't know how she swallowed a cow!" + "%s\n" % chain(7) + "%s\n" % "I don't know why she swallowed the fly. Perhaps she'll die." when 8 "I know an old lady who swallowed a %s.\n" % "horse" + "%s\n" % "She's dead, of course!" end

Slide 148

Slide 148 text

class Critter < Struct.new(:name, :qualifier) def epithet [name, qualifier].compact.join(" ") end end class Song DATA = [ ["horse"], ["cow"], ["goat"], ["dog"], ["cat"], ["bird"], ["spider", "that wriggled and jiggled and tickled inside her"], ["fly"], ] attr_reader :critters def initialize @critters = DATA.map {|row| Critter.new(*row)} end def lyrics (1..8).map {|i| verse(i)}.join("\n") end private def chain(i) critters.last(i).each_cons(2).map {|pair| motivation(*pair) }.join("\n") end def motivation(predator, prey) "She swallowed the %s to catch the %s." % [ predator.name, prey.epithet, ] end # ... end class Song # continued ... def verse(i) case i when 1 "I know an old lady who swallowed a %s.\n" % "fly" + "%s\n" % "I don't know why she swallowed the fly. Perhaps she'll die." when 2 "I know an old lady who swallowed a %s.\n" % "spider" + "%s\n" % "It wriggled and jiggled and tickled inside her." + "%s\n" % chain(2) + "%s\n" % "I don't know why she swallowed the fly. Perhaps she'll die." when 3 "I know an old lady who swallowed a %s.\n" % "bird" + "%s\n" % "How absurd to swallow a bird!" + "%s\n" % chain(3) + "%s\n" % "I don't know why she swallowed the fly. Perhaps she'll die." when 4 "I know an old lady who swallowed a %s.\n" % "cat"+ "%s\n" % "Imagine that, to swallow a cat!" + "%s\n" % chain(4) + "%s\n" % "I don't know why she swallowed the fly. Perhaps she'll die." when 5 "I know an old lady who swallowed a %s.\n" % "dog" + "%s\n" % "What a hog, to swallow a dog!" + "%s\n" % chain(5) + "%s\n" % "I don't know why she swallowed the fly. Perhaps she'll die." when 6 "I know an old lady who swallowed a %s.\n" % "goat" + "%s\n" % "Just opened her throat and swallowed a goat!" + "%s\n" % chain(6) + "%s\n" % "I don't know why she swallowed the fly. Perhaps she'll die." when 7 "I know an old lady who swallowed a %s.\n" % "cow" + "%s\n" % "I don't know how she swallowed a cow!" + "%s\n" % chain(7) + "%s\n" % "I don't know why she swallowed the fly. Perhaps she'll die." when 8 "I know an old lady who swallowed a %s.\n" % "horse" + "%s\n" % "She's dead, of course!" end end end

Slide 149

Slide 149 text

TJNJMBSJUZ

Slide 150

Slide 150 text

when 5 "I know an old lady..." % "dog" + "%s\n" % "What a hog, to swallow a dog!" + "%s\n" % chain(5) + "%s\n" % "I don't know why..." when 6 "I know an old lady..." % "goat" + "%s\n" % "Just opened her throat and swallowed a goat!" + "%s\n" % chain(6) + "%s\n" % "I don't know why..." when 7 "I know an old lady..." % "cow" + "%s\n" % "I don't know how she swallowed a cow!" + "%s\n" % chain(7) + "%s\n" % "I don't know why..." when 8

Slide 151

Slide 151 text

when 5 "I know an old lady..." % "dog" + "%s\n" % "What a hog, to swallow a dog!" + "%s\n" % chain(5) + "%s\n" % "I don't know why..." when 6 "I know an old lady..." % "goat" + "%s\n" % "Just opened her throat and swallowed a goat!" + "%s\n" % chain(6) + "%s\n" % "I don't know why..." when 7 "I know an old lady..." % "cow" + "%s\n" % "I don't know how she swallowed a cow!" + "%s\n" % chain(7) + "%s\n" % "I don't know why..." when 8

Slide 152

Slide 152 text

when 5 "I know an old lady..." % "dog" + "%s\n" % "What a hog, to swallow a dog!" + "%s\n" % chain(5) + "%s\n" % "I don't know why..." when 6 "I know an old lady..." % "goat" + "%s\n" % "Just opened her throat and swallowed a goat!" + "%s\n" % chain(6) + "%s\n" % "I don't know why..." when 7 "I know an old lady..." % "cow" + "%s\n" % "I don't know how she swallowed a cow!" + "%s\n" % chain(7) + "%s\n" % "I don't know why..." when 8

Slide 153

Slide 153 text

when 5 "I know an old lady..." % "dog" + "%s\n" % "What a hog, to swallow a dog!" + "%s\n" % chain(i) + "%s\n" % "I don't know why..." when 6 "I know an old lady..." % "goat" + "%s\n" % "Just opened her throat and swallowed a goat!" + "%s\n" % chain(i) + "%s\n" % "I don't know why..." when 7 "I know an old lady..." % "cow" + "%s\n" % "I don't know how she swallowed a cow!" + "%s\n" % chain(i) + "%s\n" % "I don't know why..." when 8

Slide 154

Slide 154 text

when 5 "I know an old lady..." % "dog" + "%s\n" % "What a hog, to swallow a dog!" + "%s\n" % chain(i) + "%s\n" % "I don't know why..." when 6 "I know an old lady..." % "goat" + "%s\n" % "Just opened her throat and swallowed a goat!" + "%s\n" % chain(i) + "%s\n" % "I don't know why..." when 7 "I know an old lady..." % "cow" + "%s\n" % "I don't know how she swallowed a cow!" + "%s\n" % chain(i) + "%s\n" % "I don't know why..." when 8

Slide 155

Slide 155 text

when 5 "I know an old lady..." % "dog" + "%s\n" % "What a hog, to swallow a dog!" + "%s\n" % chain(i) + "%s\n" % "I don't know why..." when 6 "I know an old lady..." % "goat" + "%s\n" % "Just opened her throat and swallowed a goat!" + "%s\n" % chain(i) + "%s\n" % "I don't know why..." when 7 "I know an old lady..." % "cow" + "%s\n" % "I don't know how she swallowed a cow!" + "%s\n" % chain(i) + "%s\n" % "I don't know why..." when 8

Slide 156

Slide 156 text

when 5 "I know an old lady..." % "dog" + "%s\n" % "What a hog, to swallow a dog!" + "%s\n" % chain(i) + "%s\n" % "I don't know why..." when 6 "I know an old lady..." % "goat" + "%s\n" % "Just opened her throat and swallowed a goat!" + "%s\n" % chain(i) + "%s\n" % "I don't know why..." when 7 "I know an old lady..." % "cow" + "%s\n" % "I don't know how she swallowed a cow!" + "%s\n" % chain(i) + "%s\n" % "I don't know why..." when 8

Slide 157

Slide 157 text

critters.last(i).first

Slide 158

Slide 158 text

critters.last(i).first.name

Slide 159

Slide 159 text

when 5 "I know an old lady..." % "dog" + "%s\n" % "What a hog, to swallow a dog!" + "%s\n" % chain(i) + "%s\n" % "I don't know why..." when 6 "I know an old lady..." % "goat" + "%s\n" % "Just opened her throat and swallowed a goat!" + "%s\n" % chain(i) + "%s\n" % "I don't know why..." when 7 "I know an old lady..." % "cow" + "%s\n" % "I don't know how she swallowed a cow!" + "%s\n" % chain(i) + "%s\n" % "I don't know why..." when 8

Slide 160

Slide 160 text

when 5 "I know an old lady..." % critters.last(i).first.name + "%s\n" % "What a hog, to swallow a dog!" + "%s\n" % chain(i) + "%s\n" % "I don't know why..." when 6 "I know an old lady..." % critters.last(i).first.name + "%s\n" % "Just opened her throat and swallowed a goat!" + "%s\n" % chain(i) + "%s\n" % "I don't know why..." when 7 "I know an old lady..." % critters.last(i).first.name + "%s\n" % "I don't know how she swallowed a cow!" + "%s\n" % chain(i) + "%s\n" % "I don't know why..." when 8

Slide 161

Slide 161 text

when 5 "I know an old lady..." % critters.last(i).first.name + "%s\n" % "What a hog, to swallow a dog!" + "%s\n" % chain(i) + "%s\n" % "I don't know why..." when 6 "I know an old lady..." % critters.last(i).first.name + "%s\n" % "Just opened her throat and swallowed a goat!" + "%s\n" % chain(i) + "%s\n" % "I don't know why..." when 7 "I know an old lady..." % critters.last(i).first.name + "%s\n" % "I don't know how she swallowed a cow!" + "%s\n" % chain(i) + "%s\n" % "I don't know why..." when 8

Slide 162

Slide 162 text

when 5 "I know an old lady..." % critters.last(i).first.name + "%s\n" % "What a hog, to swallow a dog!" + "%s\n" % chain(i) + "%s\n" % "I don't know why..." when 6 "I know an old lady..." % critters.last(i).first.name + "%s\n" % "Just opened her throat and swallowed a goat!" + "%s\n" % chain(i) + "%s\n" % "I don't know why..." when 7 "I know an old lady..." % critters.last(i).first.name + "%s\n" % "I don't know how she swallowed a cow!" + "%s\n" % chain(i) + "%s\n" % "I don't know why..." when 8

Slide 163

Slide 163 text

I know an old lady who swallowed a . fly I don't know why she swallowed a fly. Perhaps she'll die.

Slide 164

Slide 164 text

I know an old lady who swallowed a . spider It wriggled and jiggled and tickled inside her.

Slide 165

Slide 165 text

I know an old lady who swallowed a . bird How absurd to swallow a bird!

Slide 166

Slide 166 text

I know an old lady who swallowed a . cat Imagine that, to swallow a cat!

Slide 167

Slide 167 text

I know an old lady who swallowed a . dog What a hog, to swallow a dog!

Slide 168

Slide 168 text

I know an old lady who swallowed a . goat Just opened her throat and swallowed a goat!

Slide 169

Slide 169 text

I know an old lady who swallowed a . cow I don't know how she swallowed a cow!

Slide 170

Slide 170 text

I know an old lady who swallowed a . horse She's dead, of course!

Slide 171

Slide 171 text

critter.aside

Slide 172

Slide 172 text

class Song DATA = [ ["horse"], ["cow"], ["goat"], ["dog"], ["cat"], ["bird"], ["spider", "that wriggled ..."], ["fly"], ] end

Slide 173

Slide 173 text

class Song DATA = [ ["horse", nil, "She's dead, of course!"], ["cow", nil, "I don't know how..."], ["goat", nil, "Just opened her throat..."], ["dog", nil, "What a hog, to swallow a dog!"], ["cat", nil, "Imagine that, to swallow a cat!"], ["bird"], ["spider", "that wriggled...", "It wriggled..."], ["fly", nil, "I don't know why..."], ] end

Slide 174

Slide 174 text

when 5 "I know an old lady..." % critters.last(i).first.name + "%s\n" % "What a hog, to swallow a dog!" + "%s\n" % chain(i) + "%s\n" % "I don't know why she swallowed the fly..." when 6 "I know an old lady..." % critters.last(i).first.name + "%s\n" % "Just opened her throat and swallowed a goat!" + "%s\n" % chain(i) + "%s\n" % "I don't know why she swallowed the fly..." when 7 "I know an old lady..." % critters.last(i).first.name + "%s\n" % "I don't know how she swallowed a cow!" + "%s\n" % chain(i) + "%s\n" % "I don't know why she swallowed the fly..." when 8

Slide 175

Slide 175 text

when 5 "I know an old lady..." % critters.last(i).first.name + "%s\n" % critters.last(i).first.aside + "%s\n" % chain(i) + "%s\n" % "I don't know why she swallowed the fly..." when 6 "I know an old lady..." % critters.last(i).first.name + "%s\n" % critters.last(i).first.aside + "%s\n" % chain(i) + "%s\n" % "I don't know why she swallowed the fly..." when 7 "I know an old lady..." % critters.last(i).first.name + "%s\n" % critters.last(i).first.aside + "%s\n" % chain(i) + "%s\n" % "I don't know why she swallowed the fly..." when 8

Slide 176

Slide 176 text

when 5 "I know an old lady..." % critters.last(i).first.name + "%s\n" % critters.last(i).first.aside + "%s\n" % chain(i) + "%s\n" % "I don't know why she swallowed the fly..." when 6 "I know an old lady..." % critters.last(i).first.name + "%s\n" % critters.last(i).first.aside + "%s\n" % chain(i) + "%s\n" % "I don't know why she swallowed the fly..." when 7 "I know an old lady..." % critters.last(i).first.name + "%s\n" % critters.last(i).first.aside + "%s\n" % chain(i) + "%s\n" % "I don't know why she swallowed the fly..." when 8

Slide 177

Slide 177 text

when 4 "I know an old lady..." % critters.last(i).first.name + "%s\n" % critters.last(i).first.aside + "%s\n" % chain(i) + "%s\n" % "I don't know why she swallowed the fly. Perhaps she'll die." when 5 "I know an old lady..." % critters.last(i).first.name + "%s\n" % critters.last(i).first.aside + "%s\n" % chain(i) + "%s\n" % "I don't know why she swallowed the fly. Perhaps she'll die." when 6 "I know an old lady..." % critters.last(i).first.name + "%s\n" % critters.last(i).first.aside + "%s\n" % chain(i) + "%s\n" % "I don't know why she swallowed the fly. Perhaps she'll die." when 7 "I know an old lady..." % critters.last(i).first.name + "%s\n" % critters.last(i).first.aside + "%s\n" % chain(i) + "%s\n" % "I don't know why she swallowed the fly. Perhaps she'll die." when 8

Slide 178

Slide 178 text

case i when 1, 8 "I know an old lady..." % critters.last(i).first.name + "%s\n" % "I don't know why she swallowed the fly. Perhaps..." else "I know an old lady..." % critters.last(i).first.name + "%s\n" % critters.last(i).first.aside + "%s\n" % chain(i) + "%s\n" % "I don't know why she swallowed the fly. Perhaps..." end

Slide 179

Slide 179 text

No content

Slide 180

Slide 180 text

<<-SONG I know an old lady who swallowed a fly. I don't know why she swallowed the fly. Perhaps she'll die. I know an old lady who swallowed a spider. It wriggled and jiggled and tickled inside her. She swallowed the spider to catch the fly. I don't know why she swallowed the fly. Perhaps she'll die. I know an old lady who swallowed a bird. How absurd to swallow a bird! She swallowed the bird to catch the spider that wriggled and jiggled and tickled inside her. She swallowed the spider to catch the fly. I don't know why she swallowed the fly. Perhaps she'll die. I know an old lady who swallowed a cat. Imagine that, to swallow a cat! She swallowed the cat to catch the bird. She swallowed the bird to catch the spider that wriggled and jiggled and tickled inside her. She swallowed the spider to catch the fly. I don't know why she swallowed the fly. Perhaps she'll die. I know an old lady who swallowed a dog. What a hog, to swallow a dog! She swallowed the dog to catch the cat. She swallowed the cat to catch the bird. She swallowed the bird to catch the spider that wriggled and jiggled and tickled inside her. She swallowed the spider to catch the fly. I don't know why she swallowed the fly. Perhaps she'll die. I know an old lady who swallowed a goat. Just opened her throat and swallowed a goat! She swallowed the goat to catch the dog. She swallowed the dog to catch the cat. She swallowed the cat to catch the bird. She swallowed the bird to catch the spider that wriggled and jiggled and tickled inside her. She swallowed the spider to catch the fly. I don't know why she swallowed the fly. Perhaps she'll die. I know an old lady who swallowed a cow. I don't know how she swallowed a cow! She swallowed the cow to catch the goat. She swallowed the goat to catch the dog. She swallowed the dog to catch the cat. She swallowed the cat to catch the bird. She swallowed the bird to catch the spider that wriggled and jiggled and tickled inside her. She swallowed the spider to catch the fly. I don't know why she swallowed the fly. Perhaps she'll die. I know an old lady who swallowed a horse. She's dead, of course! SONG

Slide 181

Slide 181 text

case i when 1 "I know an old lady who swallowed a fly.\n" + "I don't know why she swallowed the fly. Perhaps she'll die.\n" when 2 "I know an old lady who swallowed a spider.\n" + "It wriggled and jiggled and tickled inside her.\n" + "She swallowed the spider to catch the fly.\n" + "I don't know why she swallowed the fly. Perhaps she'll die.\n" when 3 "I know an old lady who swallowed a bird.\n" + "How absurd to swallow a bird!\n" + "She swallowed the bird to catch the spider that wriggled and jiggled and tickled inside her.\n" + "She swallowed the spider to catch the fly.\n" + "I don't know why she swallowed the fly. Perhaps she'll die.\n" when 4 "I know an old lady who swallowed a cat.\n" + "Imagine that, to swallow a cat!\n" + "She swallowed the cat to catch the bird.\n" + "She swallowed the bird to catch the spider that wriggled and jiggled and tickled inside her.\n" + "She swallowed the spider to catch the fly.\n" + "I don't know why she swallowed the fly. Perhaps she'll die.\n" when 5 "I know an old lady who swallowed a dog.\n" + "What a hog, to swallow a dog!\n" + "She swallowed the dog to catch the cat.\n" + "She swallowed the cat to catch the bird.\n" + "She swallowed the bird to catch the spider that wriggled and jiggled and tickled inside her.\n" + "She swallowed the spider to catch the fly.\n" + "I don't know why she swallowed the fly. Perhaps she'll die.\n" when 6 "I know an old lady who swallowed a goat.\n" + "Just opened her throat and swallowed a goat!\n" + "She swallowed the goat to catch the dog.\n" + "She swallowed the dog to catch the cat.\n" + "She swallowed the cat to catch the bird.\n" + "She swallowed the bird to catch the spider that wriggled and jiggled and tickled inside her.\n" + "She swallowed the spider to catch the fly.\n" + "I don't know why she swallowed the fly. Perhaps she'll die.\n" when 7 "I know an old lady who swallowed a cow.\n" + "I don't know how she swallowed a cow!\n" + "She swallowed the cow to catch the goat.\n" + "She swallowed the goat to catch the dog.\n" + "She swallowed the dog to catch the cat.\n" + "She swallowed the cat to catch the bird.\n" + "She swallowed the bird to catch the spider that wriggled and jiggled and tickled inside her.\n" + "She swallowed the spider to catch the fly.\n" + "I don't know why she swallowed the fly. Perhaps she'll die.\n" when 8 "I know an old lady who swallowed a horse.\n" + "She's dead, of course!\n" end

Slide 182

Slide 182 text

case i when 1 "I know an old lady who swallowed a %s.\n" % "fly" + "%s\n" % "I don't know why she swallowed the fly. Perhaps she'll die." when 2 "I know an old lady who swallowed a %s.\n" % "spider" + "%s\n" % "It wriggled and jiggled and tickled inside her." + "She swallowed the %s to catch the %s.\n" % ["spider", "fly"] + "%s\n" % "I don't know why she swallowed the fly. Perhaps she'll die." when 3 "I know an old lady who swallowed a %s.\n" % "bird" + "%s\n" % "How absurd to swallow a bird!" + "She swallowed the %s to catch the %s.\n" % ["bird", "spider that wriggled and jiggled and tickled inside her"] + "She swallowed the %s to catch the %s.\n" % ["spider", "fly"] + "%s\n" % "I don't know why she swallowed the fly. Perhaps she'll die." when 4 "I know an old lady who swallowed a %s.\n" % "cat"+ "%s\n" % "Imagine that, to swallow a cat!" + "She swallowed the %s to catch the %s.\n" % ["cat", "bird"] + "She swallowed the %s to catch the %s.\n" % ["bird", "spider that wriggled and jiggled and tickled inside her"] + "She swallowed the %s to catch the %s.\n" % ["spider", "fly"] + "%s\n" % "I don't know why she swallowed the fly. Perhaps she'll die." when 5 "I know an old lady who swallowed a %s.\n" % "dog" + "%s\n" % "What a hog, to swallow a dog!" + "She swallowed the %s to catch the %s.\n" % ["dog", "cat"] + "She swallowed the %s to catch the %s.\n" % ["cat", "bird"] + "She swallowed the %s to catch the %s.\n" % ["bird", "spider that wriggled and jiggled and tickled inside her"] + "She swallowed the %s to catch the %s.\n" % ["spider", "fly"] + "%s\n" % "I don't know why she swallowed the fly. Perhaps she'll die." when 6 "I know an old lady who swallowed a %s.\n" % "goat" + "%s\n" % "Just opened her throat and swallowed a goat!" + "She swallowed the %s to catch the %s.\n" % ["goat", "dog"] + "She swallowed the %s to catch the %s.\n" % ["dog", "cat"] + "She swallowed the %s to catch the %s.\n" % ["cat", "bird"] + "She swallowed the %s to catch the %s.\n" % ["bird", "spider that wriggled and jiggled and tickled inside her"] + "She swallowed the %s to catch the %s.\n" % ["spider", "fly"] + "%s\n" % "I don't know why she swallowed the fly. Perhaps she'll die." when 7 "I know an old lady who swallowed a %s.\n" % "cow" + "%s\n" % "I don't know how she swallowed a cow!" + "She swallowed the %s to catch the %s.\n" % ["cow", "goat"] + "She swallowed the %s to catch the %s.\n" % ["goat", "dog"] + "She swallowed the %s to catch the %s.\n" % ["dog", "cat"] + "She swallowed the %s to catch the %s.\n" % ["cat", "bird"] + "She swallowed the %s to catch the %s.\n" % ["bird", "spider that wriggled and jiggled and tickled inside her"] + "She swallowed the %s to catch the %s.\n" % ["spider", "fly"] + "%s\n" % "I don't know why she swallowed the fly. Perhaps she'll die." when 8 "I know an old lady who swallowed a %s.\n" % "horse" + "%s\n" % "She's dead, of course!" end

Slide 183

Slide 183 text

def verse(i) case i when 1 "I know an old lady who swallowed a %s.\n" % "fly" + "%s\n" % "I don't know why she swallowed the fly. Perhaps she'll die." when 2 "I know an old lady who swallowed a %s.\n" % "spider" + "%s\n" % "It wriggled and jiggled and tickled inside her." + "%s\n" % chain(2) + "%s\n" % "I don't know why she swallowed the fly. Perhaps she'll die." when 3 "I know an old lady who swallowed a %s.\n" % "bird" + "%s\n" % "How absurd to swallow a bird!" + "%s\n" % chain(3) + "%s\n" % "I don't know why she swallowed the fly. Perhaps she'll die." when 4 "I know an old lady who swallowed a %s.\n" % "cat"+ "%s\n" % "Imagine that, to swallow a cat!" + "%s\n" % chain(4) + "%s\n" % "I don't know why she swallowed the fly. Perhaps she'll die." when 5 "I know an old lady who swallowed a %s.\n" % "dog" + "%s\n" % "What a hog, to swallow a dog!" + "%s\n" % chain(5) + "%s\n" % "I don't know why she swallowed the fly. Perhaps she'll die." when 6 "I know an old lady who swallowed a %s.\n" % "goat" + "%s\n" % "Just opened her throat and swallowed a goat!" + "%s\n" % chain(6) + "%s\n" % "I don't know why she swallowed the fly. Perhaps she'll die." when 7 "I know an old lady who swallowed a %s.\n" % "cow" + "%s\n" % "I don't know how she swallowed a cow!" + "%s\n" % chain(7) + "%s\n" % "I don't know why she swallowed the fly. Perhaps she'll die." when 8 "I know an old lady who swallowed a %s.\n" % "horse" + "%s\n" % "She's dead, of course!" end end def chain(i) critters.last(i).each_cons(2).map {|pair| motivation(*pair) }.join("\n") end def motivation(predator, prey) "She swallowed the %s to catch the %s." % [ predator.name, prey.epithet, ] end

Slide 184

Slide 184 text

class Critter < Struct.new(:name, :qualifier, :aside) def epithet [name, qualifier].compact.join(" ") end end

Slide 185

Slide 185 text

case i when 1 "I know an old lady who swallowed a %s.\n" % "fly" + "%s\n" % "I don't know why she swallowed the fly. Perhaps she'll die." when 2 "I know an old lady who swallowed a %s.\n" % "spider" + "%s\n" % "It wriggled and jiggled and tickled inside her." + "%s\n" % chain(2) + "%s\n" % "I don't know why she swallowed the fly. Perhaps she'll die." when 3 "I know an old lady who swallowed a %s.\n" % "bird" + "%s\n" % "How absurd to swallow a bird!" + "%s\n" % chain(3) + "%s\n" % "I don't know why she swallowed the fly. Perhaps she'll die." when 4 "I know an old lady who swallowed a %s.\n" % "cat"+ "%s\n" % "Imagine that, to swallow a cat!" + "%s\n" % chain(4) + "%s\n" % "I don't know why she swallowed the fly. Perhaps she'll die." when 5 "I know an old lady who swallowed a %s.\n" % "dog" + "%s\n" % "What a hog, to swallow a dog!" + "%s\n" % chain(5) + "%s\n" % "I don't know why she swallowed the fly. Perhaps she'll die." when 6 "I know an old lady who swallowed a %s.\n" % "goat" + "%s\n" % "Just opened her throat and swallowed a goat!" + "%s\n" % chain(6) + "%s\n" % "I don't know why she swallowed the fly. Perhaps she'll die." when 7 "I know an old lady who swallowed a %s.\n" % "cow" + "%s\n" % "I don't know how she swallowed a cow!" + "%s\n" % chain(7) + "%s\n" % "I don't know why she swallowed the fly. Perhaps she'll die." when 8 "I know an old lady who swallowed a %s.\n" % "horse" + "%s\n" % "She's dead, of course!" end

Slide 186

Slide 186 text

case i when 1 "I know an old lady who swallowed a %s.\n" % critters.last(i).first.name + "%s\n" % critters.last(i).first.aside when 2 "I know an old lady who swallowed a %s.\n" % critters.last(i).first.name + "%s\n" % critters.last(i).first.aside + "%s\n" % chain(i) + "%s\n" % "I don't know why she swallowed the fly. Perhaps she'll die." when 3 "I know an old lady who swallowed a %s.\n" % critters.last(i).first.name + "%s\n" % critters.last(i).first.aside + "%s\n" % chain(i) + "%s\n" % "I don't know why she swallowed the fly. Perhaps she'll die." when 4 "I know an old lady who swallowed a %s.\n" % critters.last(i).first.name + "%s\n" % critters.last(i).first.aside + "%s\n" % chain(i) + "%s\n" % "I don't know why she swallowed the fly. Perhaps she'll die." when 5 "I know an old lady who swallowed a %s.\n" % critters.last(i).first.name + "%s\n" % critters.last(i).first.aside + "%s\n" % chain(i) + "%s\n" % "I don't know why she swallowed the fly. Perhaps she'll die." when 6 "I know an old lady who swallowed a %s.\n" % critters.last(i).first.name + "%s\n" % critters.last(i).first.aside + "%s\n" % chain(i) + "%s\n" % "I don't know why she swallowed the fly. Perhaps she'll die." when 7 "I know an old lady who swallowed a %s.\n" % critters.last(i).first.name + "%s\n" % critters.last(i).first.aside + "%s\n" % chain(i) + "%s\n" % "I don't know why she swallowed the fly. Perhaps she'll die." when 8 "I know an old lady who swallowed a %s.\n" % critters.last(i).first.name + "%s\n" % critters.last(i).first.aside end

Slide 187

Slide 187 text

case i when 1, 8 "I know an old lady who swallowed a %s.\n" % critters.last(i).first.name + "%s\n" % critters.last(i).first.aside else "I know an old lady who swallowed a %s.\n" % critters.last(i).first.name + "%s\n" % critters.last(i).first.aside + "%s\n" % chain(i) + "%s\n" % "I don't know why she swallowed the fly. Perhaps she'll die." end

Slide 188

Slide 188 text

DPIFTJPO

Slide 189

Slide 189 text

class Song def initialize # ... def lyrics # ... private def verse(i) # ... def chain(i) # ... def motivation(predator, prey) # ... end

Slide 190

Slide 190 text

class Song def initialize # ... def lyrics # ... private def verse(i) # ... def chain(i) # ... def motivation(predator, prey) # ... end

Slide 191

Slide 191 text

class Song def initialize # ... def lyrics # ... end class Verse def verse(i) # ... def chain(i) # ... def motivation(predator, prey) # ... end

Slide 192

Slide 192 text

class Song def initialize # ... def lyrics # ... private def verse(i) # ... def chain(i) # ... def motivation(predator, prey) # ... end class Verse # ... end

Slide 193

Slide 193 text

class Verse def verse(i) # ... def chain(i) # ... def motivation(predator, prey) # ... end

Slide 194

Slide 194 text

critters.last(i)

Slide 195

Slide 195 text

class Verse def verse(i) # ... def chain(i) # ... def motivation(predator, prey) # ... end

Slide 196

Slide 196 text

class Verse def initialize(critters) # ... def verse(i) # ... def chain(i) # ... def motivation(predator, prey) # ... end

Slide 197

Slide 197 text

class Verse attr_reader :critters def initialize(critters) # ... def verse(i) # ... def chain(i) # ... def motivation(predator, prey) # ... end

Slide 198

Slide 198 text

Verse.new(critters)

Slide 199

Slide 199 text

Verse.new(critters.last(i))

Slide 200

Slide 200 text

class Verse attr_reader :critters def initialize(critters) # ... def verse(i) # ... def chain(i) # ... def motivation(predator, prey) # ... end

Slide 201

Slide 201 text

class Verse attr_reader :critters def initialize(critters) # ... def verse # ... def chain # ... def motivation(predator, prey) # ... end

Slide 202

Slide 202 text

class Verse attr_reader :critters, :i def initialize(critters) @critters = critters @i = critters.length end # ... end

Slide 203

Slide 203 text

Verse.new(critters.last(i)).verse

Slide 204

Slide 204 text

Verse.new(critters.last(i)).to_s

Slide 205

Slide 205 text

class Verse attr_reader :critters, :i def initialize(critters) # ... def to_s # ... def chain # ... def motivation(predator, prey) # ... end

Slide 206

Slide 206 text

class Verse attr_reader :critters, i def initialize(critters) # ... def to_s # ... def chain # ... def motivation(predator, prey) # ... end

Slide 207

Slide 207 text

class Verse attr_reader :critters, i def initialize(critters) # ... def to_s # ... private def chain # ... def motivation(predator, prey) # ... end

Slide 208

Slide 208 text

class Song def initialize # ... def lyrics (1..8).map {|i| verse(i) }.join("\n") end private def verse(i) # ... def chain(i) # ... def motivation(predator, prey) # ... end

Slide 209

Slide 209 text

class Song def initialize # ... def lyrics (1..8).map {|i| verse(i) }.join("\n") end private def verse(i) # ... def chain(i) # ... def motivation(predator, prey) # ... end

Slide 210

Slide 210 text

class Song def initialize # ... def lyrics (1..8).map {|i| Verse.new(critters.last(i)) }.join("\n") end private def verse(i) # ... def chain(i) # ... def motivation(predator, prey) # ... end

Slide 211

Slide 211 text

class Song def initialize # ... def lyrics (1..8).map {|i| Verse.new(critters.last(i)) }.join("\n") end end

Slide 212

Slide 212 text

# Running: . 1 assertions, 0 failures, 0 errors, 0 skips

Slide 213

Slide 213 text

class Verse attr_reader :critters, :i def initialize(critters) @critters = critters @i = critters.length end def to_s case i when 1, 8 "I know an old lady who swallowed a %s.\n" % critters.last(i).first.name + "%s\n" % critters.last(i).first.aside else "I know an old lady who swallowed a %s.\n" % critters.last(i).first.name + "%s\n" % critters.last(i).first.aside + "%s\n" % chain + "%s\n" % "I don't know why she swallowed the fly. Perhaps she'll die." end end private def chain critters.last(i).each_cons(2).map {|pair| motivation(*pair) }.join("\n") end def motivation(predator, prey) "She swallowed the %s to catch the %s." % [ predator.name, prey.epithet, ] end end class Critter < Struct.new(:name, :qualifier, :aside) def epithet [name, qualifier].compact.join(" ") end end class Song DATA = [ ["horse", nil, "She's dead, of course!"], ["cow", nil, "I don't know how she swallowed a cow!"], ["goat", nil, "Just opened her throat and swallowed a goat!"], ["dog", nil, "What a hog, to swallow a dog!"], ["cat", nil, "Imagine that, to swallow a cat!"], ["bird", nil, "How absurd to swallow a bird!"], [ "spider", "that wriggled and jiggled and tickled inside her", "It wriggled and jiggled and tickled inside her.", ], ["fly", nil, "I don't know why she swallowed the fly. Perhaps she'll die."], ] attr_reader :critters def initialize @critters = DATA.map {|row| Critter.new(*row)} end def lyrics (1..8).map {|i| Verse.new(critters.last(i)) }.join("\n") end end

Slide 214

Slide 214 text

class Critter < Struct.new(:name, :qualifier, :aside) def epithet [name, qualifier].compact.join(" ") end end

Slide 215

Slide 215 text

class Song DATA = [ ["horse", nil, "She's dead, of course!"], ["cow", nil, "I don't know how she swallowed a cow!"], ["goat", nil, "Just opened her throat and swallowed a goat!"], ["dog", nil, "What a hog, to swallow a dog!"], ["cat", nil, "Imagine that, to swallow a cat!"], ["bird", nil, "How absurd to swallow a bird!"], [ "spider", "that wriggled and jiggled and tickled inside her", "It wriggled and jiggled and tickled inside her.", ], ["fly", nil, "I don't know why she swallowed the fly. Perhaps she'll die."], ] attr_reader :critters def initialize @critters = DATA.map {|row| Critter.new(*row)} end def lyrics (1..8).map {|i| Verse.new(critters.last(i)) }.join("\n") end end

Slide 216

Slide 216 text

class Verse attr_reader :critters, :i def initialize(critters) @critters = critters @i = critters.length end def to_s case i when 1, 8 "I know an old lady who swallowed a %s.\n" % critters.last(i).first.name + "%s\n" % critters.last(i).first.aside else "I know an old lady who swallowed a %s.\n" % critters.last(i).first.name + "%s\n" % critters.last(i).first.aside + "%s\n" % chain + "%s\n" % "I don't know why she swallowed the fly. Perhaps she'll die." end end private def chain critters.last(i).each_cons(2).map {|pair| motivation(*pair) }.join("\n") end def motivation(predator, prey) "She swallowed the %s to catch the %s." % [ predator.name, prey.epithet, ] end end

Slide 217

Slide 217 text

No content

Slide 218

Slide 218 text

SFTJEVF

Slide 219

Slide 219 text

case i when 1, 8 "I know an old lady..." % critters.last(i).first.name + "%s\n" % critters.last(i).first.aside else "I know an old lady..." % critters.last(i).first.name + "%s\n" % critters.last(i).first.aside + "%s\n" % chain + "%s\n" % "I don't know why she swallowed the fly. Perhaps she'll die." end

Slide 220

Slide 220 text

case i when 1, 8 "I know an old lady..." % critters.last(i).first.name + "%s\n" % critters.last(i).first.aside else "I know an old lady..." % critters.last(i).first.name + "%s\n" % critters.last(i).first.aside + "%s\n" % chain + "%s\n" % "I don't know why she swallowed the fly. Perhaps she'll die." end

Slide 221

Slide 221 text

case i when 1, 8 "I know an old lady..." % critters.last(i).first.name + "%s\n" % critters.last(i).first.aside else "I know an old lady..." % critters.last(i).first.name + "%s\n" % critters.last(i).first.aside + "%s\n" % chain + "%s\n" % "I don't know why she swallowed the fly. Perhaps she'll die." end

Slide 222

Slide 222 text

case i when 1, 8 "" else "%s\n" % chain + "%s\n" % "I don't know why she swallowed..." end

Slide 223

Slide 223 text

def summary case i when 1, 8 "" else "%s\n" % chain + "%s\n" % "I don't know why she swallowed..." end end

Slide 224

Slide 224 text

def recap case i when 1, 8 "" else "%s\n" % chain + "%s\n" % "I don't know why she swallowed..." end end

Slide 225

Slide 225 text

"I know an old lady who swallowed a %s.\n%s\n" % [ critters.last(i).first.name, critters.last(i).first.aside, ]

Slide 226

Slide 226 text

def incident "I know an old lady who swallowed a %s.\n%s\n" % [ critters.last(i).first.name, critters.last(i).first.aside, ] end

Slide 227

Slide 227 text

def to_s incident + recap end

Slide 228

Slide 228 text

def incident "I know an old lady who swallowed a %s.\n%s\n" % [ critters.last(i).first.name, critters.last(i).first.aside, ] end def recap case i when 1, 8 "" else "%s\n" % chain + "%s\n" % "I don't know why she swallowed the fly..." end end

Slide 229

Slide 229 text

def incident "I know an old lady who swallowed a %s.\n%s\n" % [ critters.last(i).first.name, critters.last(i).first.aside, ] end def chain critters.last(i).each_cons(2).map {|pair| motivation(*pair) }.join("\n") end

Slide 230

Slide 230 text

def incident "I know an old lady who swallowed a %s.\n%s\n" % [ critters.first.name, critters.first.aside, ] end def chain critters.each_cons(2).map {|pair| motivation(*pair) }.join("\n") end

Slide 231

Slide 231 text

attr_reader :critters, :i def initialize(critters) @critters = critters @i = critters.length end def to_s case i when 1, 8 # ... else # ... end end

Slide 232

Slide 232 text

attr_reader :critters, :i def initialize(critters) @critters = critters @i = critters.length end def to_s case i when 1, 8 # ... else # ... end end

Slide 233

Slide 233 text

attr_reader :critters def initialize(critters) @critters = critters end def to_s case critters.length when 1, 8 # ... else # ... end end

Slide 234

Slide 234 text

attr_reader :critters def initialize(critters) @critters = critters end def incident "I know an old lady who swallowed a %s.\n%s\n" % [ critters.first.name, critters.first.aside, ] end

Slide 235

Slide 235 text

attr_reader :critters def initialize(critters) @critters = critters end def incident "I know an old lady who swallowed a %s.\n%s\n" % [ critters.first.name, critters.first.aside, ] end

Slide 236

Slide 236 text

attr_reader :critters, :critter def initialize(critters) @critters = critters @critter = critters.first end def incident "I know an old lady who swallowed a %s.\n%s\n" % [ critter.name, critter.aside, ] end

Slide 237

Slide 237 text

def incident "I know an old lady who swallowed a %s.\n%s\n" % [ critter.name, critter.aside, ] end def recap case critters.length when 1, 8 "" else "%s\n" % chain + "%s\n" % "I don't know why she swallowed the fly. Perhaps she'll die." end end def motivation(predator, prey) "She swallowed the %s to catch the %s." % [ predator.name, prey.epithet, ] end

Slide 238

Slide 238 text

def incident "I know an old lady who swallowed a %s.\n%s\n" % [ critter.name, critter.aside, ] end def recap case critters.length when 1, 8 "" else "%s\n" % chain + "%s\n" % "I don't know why she swallowed the fly. Perhaps she'll die." end end def motivation(predator, prey) "She swallowed the %s to catch the %s." % [ predator.name, prey.epithet, ] end

Slide 239

Slide 239 text

def incident "I know an old lady who swallowed a %s.\n%s\n" % [ critter.name, critter.aside, ] end def recap case critters.length when 1, 8 "" else "%s\n" % chain + "%s\n" % "I don't know why she swallowed the fly. Perhaps she'll die." end end def motivation(predator, prey) "She swallowed the %s to catch the %s." % [ predator.name, prey.epithet, ] end

Slide 240

Slide 240 text

def incident "I know an old lady who swallowed a %s.\n%s\n" % [ critter.name, critter.aside, ] end def recap case critters.length when 1, 8 "" else "%s\n" % chain + "%s\n" % critters.last.aside end end def motivation(predator, prey) "She swallowed the %s to catch the %s." % [ predator.name, prey.epithet, ] end

Slide 241

Slide 241 text

class Verse attr_reader :critters, :critter def initialize(critters) @critters = critters @critter = critters.first end def to_s incident + recap end private def incident "I know an old lady who swallowed a %s.\n%s\n" % [ critter.name, critter.aside, ] end def recap case critters.length when 1, 8 "" else "%s\n" % chain + "%s\n" % critters.last.aside end end def chain critters.each_cons(2).map {|pair| motivation(*pair) }.join("\n") end def motivation(predator, prey) "She swallowed the %s to catch the %s." % [ predator.name, prey.epithet, ] end end attr_reader :critters, :critter def initialize(critters) @critters = critters @critter = critters.first end

Slide 242

Slide 242 text

def to_s incident + recap end class Verse attr_reader :critters, :critter def initialize(critters) @critters = critters @critter = critters.first end def to_s incident + recap end private def incident "I know an old lady who swallowed a %s.\n%s\n" % [ critter.name, critter.aside, ] end def recap case critters.length when 1, 8 "" else "%s\n" % chain + "%s\n" % critters.last.aside end end def chain critters.each_cons(2).map {|pair| motivation(*pair) }.join("\n") end def motivation(predator, prey) "She swallowed the %s to catch the %s." % [ predator.name, prey.epithet, ] end end

Slide 243

Slide 243 text

def incident "I know an old lady..." % [ critter.name, critter.aside, ] end class Verse attr_reader :critters, :critter def initialize(critters) @critters = critters @critter = critters.first end def to_s incident + recap end private def incident "I know an old lady who swallowed a %s.\n%s\n" % [ critter.name, critter.aside, ] end def recap case critters.length when 1, 8 "" else "%s\n" % chain + "%s\n" % critters.last.aside end end def chain critters.each_cons(2).map {|pair| motivation(*pair) }.join("\n") end def motivation(predator, prey) "She swallowed the %s to catch the %s." % [ predator.name, prey.epithet, ] end end

Slide 244

Slide 244 text

class Verse attr_reader :critters, :critter def initialize(critters) @critters = critters @critter = critters.first end def to_s incident + recap end private def incident "I know an old lady who swallowed a %s.\n%s\n" % [ critter.name, critter.aside, ] end def recap case critters.length when 1, 8 "" else "%s\n" % chain + "%s\n" % critters.last.aside end end def chain critters.each_cons(2).map {|pair| motivation(*pair) }.join("\n") end def motivation(predator, prey) "She swallowed the %s to catch the %s." % [ predator.name, prey.epithet, ] end end def recap case critters.length when 1, 8 "" else "%s\n" % chain + "%s\n" % critters.last.aside end end

Slide 245

Slide 245 text

def chain critters.each_cons(2).map {|pair| motivation(*pair) }.join("\n") end class Verse attr_reader :critters, :critter def initialize(critters) @critters = critters @critter = critters.first end def to_s incident + recap end private def incident "I know an old lady who swallowed a %s.\n%s\n" % [ critter.name, critter.aside, ] end def recap case critters.length when 1, 8 "" else "%s\n" % chain + "%s\n" % critters.last.aside end end def chain critters.each_cons(2).map {|pair| motivation(*pair) }.join("\n") end def motivation(predator, prey) "She swallowed the %s to catch the %s." % [ predator.name, prey.epithet, ] end end

Slide 246

Slide 246 text

def motivation(predator, prey) "... %s to catch the %s." % [ predator.name, prey.epithet, ] end class Verse attr_reader :critters, :critter def initialize(critters) @critters = critters @critter = critters.first end def to_s incident + recap end private def incident "I know an old lady who swallowed a %s.\n%s\n" % [ critter.name, critter.aside, ] end def recap case critters.length when 1, 8 "" else "%s\n" % chain + "%s\n" % critters.last.aside end end def chain critters.each_cons(2).map {|pair| motivation(*pair) }.join("\n") end def motivation(predator, prey) "She swallowed the %s to catch the %s." % [ predator.name, prey.epithet, ] end end

Slide 247

Slide 247 text

No content

Slide 248

Slide 248 text

QPMZNPSQIJTN

Slide 249

Slide 249 text

OPQF

Slide 250

Slide 250 text

DIBOHF

Slide 251

Slide 251 text

No content

Slide 252

Slide 252 text

No content

Slide 253

Slide 253 text

No content

Slide 254

Slide 254 text

class Song DATA = [...] # ... end

Slide 255

Slide 255 text

class Song DATA = [...] def initialize @critters = DATA.map {|row| Critter.new(*row)} end # ... end

Slide 256

Slide 256 text

class Song DATA = [...] def initialize(data=DATA) @critters = DATA.map {|row| Critter.new(*row)} end # ... end

Slide 257

Slide 257 text

class Song DATA = [...] def initialize(data=DATA) @critters = data.map {|row| Critter.new(*row)} end # ... end

Slide 258

Slide 258 text

def lyrics (1..8).map {|i| Verse.new(critters.last(i)) }.join("\n") end

Slide 259

Slide 259 text

def lyrics (1..8).map {|i| Verse.new(critters.last(i)) }.join("\n") end

Slide 260

Slide 260 text

def lyrics (1..critters.length).map {|i| Verse.new(critters.last(i)) }.join("\n") end

Slide 261

Slide 261 text

class Verse # ... def recap case critters.length when 1, 8 "" else "%s\n" % chain + "%s\n" % critters.last.aside end end # ... end

Slide 262

Slide 262 text

PQUJPOT

Slide 263

Slide 263 text

Verse.new(critters.last(i))

Slide 264

Slide 264 text

Verse.new(critters.last(i)) Verse.new(critters.last(i), critters.length)

Slide 265

Slide 265 text

Verse.new(critters.last(i)) Verse.new(critters.last(i), critters.length) Verse.new(critters, i)

Slide 266

Slide 266 text

Verse.new(critters.last(i)) Verse.new(critters.last(i), critters.length) Verse.new(critters, i) Verse.new(critters.last(i), :short)

Slide 267

Slide 267 text

PQUJPOT

Slide 268

Slide 268 text

QPMZNPSQIJTN

Slide 269

Slide 269 text

class Verse # ... def recap case critters.length when 1, 8 "" else "%s\n" % chain + "%s\n" % critters.last.aside end end end

Slide 270

Slide 270 text

class LongVerse # ... def recap end end class ShortVerse # ... def recap end end

Slide 271

Slide 271 text

# else class LongVerse # ... def recap "%s\n" % chain + "%s\n" % critters.last.aside end end # when 1, 8 class ShortVerse # ... def recap "" end end

Slide 272

Slide 272 text

# else class LongVerse # ... def recap "%s\n" % chain + "%s\n" % critters.last.aside end end # when 1, 8 class ShortVerse # ... def recap "" end end

Slide 273

Slide 273 text

# else class LongVerse # ... def recap "%s\n" % chain + "%s\n" % critters.last.aside end def chain # ... def motivation(predator, prey) # ... end # when 1, 8 class ShortVerse # ... def recap "" end end

Slide 274

Slide 274 text

class {Short,Long}Verse attr_reader :critters def initialize(critters) # ... def to_s # ... private def recap # ... end end

Slide 275

Slide 275 text

class ShortVerse attr_reader :critters def initialize(critters) # ... def to_s # ... private def recap "" end end

Slide 276

Slide 276 text

class LongVerse < ShortVerse end

Slide 277

Slide 277 text

class LongVerse < ShortVerse private def recap "%s\n" % chain + "%s\n" % critters.last.aside end end

Slide 278

Slide 278 text

class LongVerse < ShortVerse private def recap "%s\n" % chain + "%s\n" % critters.last.aside end def chain # ... def motivation(predator, prey) # ... end

Slide 279

Slide 279 text

class Song # ... def lyrics (1..critters.length).map {|i| ???.???(critters, i) }.join("\n") end # ... end

Slide 280

Slide 280 text

case i when 1, critters.length ShortVerse else LongVerse end

Slide 281

Slide 281 text

case i when 1, critters.length ShortVerse else LongVerse end.new(critters.last(i))

Slide 282

Slide 282 text

class Song def self.verse_builder(critters, i) case i when 1, critters.length ShortVerse else LongVerse end.new(critters.last(i)) end end

Slide 283

Slide 283 text

class Verse def self.for(critters, i) case i when 1, critters.length ShortVerse else LongVerse end.new(critters.last(i)) end end

Slide 284

Slide 284 text

class Song # ... def lyrics (1..critters.length).map {|i| Verse.for(critters, i) }.join("\n") end # ... end

Slide 285

Slide 285 text

qFYJCJMJUZ

Slide 286

Slide 286 text

data = [ ["D", nil, "Nope."], ["C", nil, "ZOMG C!"], ["B", "that blah blah", "Squee, B!"], ["A", nil, "IDK why A."], ]

Slide 287

Slide 287 text

<<-SONG I know an old lady who swallowed an A. IDK why A. I know an old lady who swallowed a B. Squee, B! She swallowed the B to catch the A. IDK why A. I know an old lady who swallowed a C. ZOMG C! She swallowed the C to catch the B that blah blah. She swallowed the B to catch the A. IDK why A. I know an old lady who swallowed a D. Nope. SONG

Slide 288

Slide 288 text

<<-SONG I know an old lady who swallowed an A. IDK why A. I know an old lady who swallowed a B. Squee, B! She swallowed the B to catch the A. IDK why A. I know an old lady who swallowed a C. ZOMG C! She swallowed the C to catch the B that blah blah. She swallowed the B to catch the A. IDK why A. I know an old lady who swallowed a D. Nope. SONG

Slide 289

Slide 289 text

<<-SONG I know an old lady who swallowed an A. IDK why A. I know an old lady who swallowed a B. Squee, B! She swallowed the B to catch the A. IDK why A. I know an old lady who swallowed a C. ZOMG C! She swallowed the C to catch the B that blah blah. She swallowed the B to catch the A. IDK why A. I know an old lady who swallowed a D. Nope. SONG

Slide 290

Slide 290 text

<<-SONG I know an old lady who swallowed an A. IDK why A. I know an old lady who swallowed a B. Squee, B! She swallowed the B to catch the A. IDK why A. I know an old lady who swallowed a C. ZOMG C! She swallowed the C to catch the B that blah blah. She swallowed the B to catch the A. IDK why A. I know an old lady who swallowed a D. Nope. SONG

Slide 291

Slide 291 text

assert_equal expected, Song.new(data).lyrics

Slide 292

Slide 292 text

1) Failure: SongTest#test_alt_critters [song_test.rb:90]: --- expected +++ actual @@ -1,4 +1,4 @@ -"I know an old lady who swallowed an A. +"I know an old lady who swallowed a A.

Slide 293

Slide 293 text

[FCSB B

Slide 294

Slide 294 text

BMMJHBUPS BO

Slide 295

Slide 295 text

class Critter < Struct.new(:name, :qualifier, :aside) def epithet [name, qualifier].compact.join(" ") end def article if name[0] =~ /[aeiouAEIOU]/ "an" else "a" end end end

Slide 296

Slide 296 text

# Running: .. 2 assertions, 0 failures, 0 errors, 0 skips

Slide 297

Slide 297 text

UIFONBLFUIFFBTZDIBOHF - Kent Beck NBLFUIFDIBOHFFBTZ XBSOJOHUIJTNBZCFIBSE

Slide 298

Slide 298 text

SFGBDUPSJOH is insight

Slide 299

Slide 299 text

UIBOLZPV

Slide 300

Slide 300 text

HJUIVCDPNLZUSJOZY succession

Slide 301

Slide 301 text

Katrina Owen Sandi Metz & by CPUUMFTCPPLDPN

Slide 302

Slide 302 text

FYFSDJTN JP IUUQ

Slide 303

Slide 303 text

Katrina Owen FYFSDJTNJP !LZUSJOZY

Slide 304

Slide 304 text

UIBOLT <3