Sha256: 74a2ed9ec9019009fa113f5feff3a320250a4e58250bebabcb984f027444f690

Contents?: true

Size: 836 Bytes

Versions: 396

Compression:

Stored size: 836 Bytes

Contents

class House
  def self.recite
    new.recite
  end

  def recite
    (1..pieces.length).map { |i| line(i) }.join("\n")
  end

  def line(i)
    "This is %s.\n" % pieces.last(i).map { |s| s.join("\n") }.join(' ')
  end

  private

  def pieces
    [
      ['the horse and the hound and the horn', 'that belonged to'],
      ['the farmer sowing his corn', 'that kept'],
      ['the rooster that crowed in the morn', 'that woke'],
      ['the priest all shaven and shorn', 'that married'],
      ['the man all tattered and torn', 'that kissed'],
      ['the maiden all forlorn', 'that milked'],
      ['the cow with the crumpled horn', 'that tossed'],
      ['the dog', 'that worried'],
      ['the cat', 'that killed'],
      ['the rat', 'that ate'],
      ['the malt', 'that lay in'],
      ['the house that Jack built']
    ]
  end
end

Version data entries

396 entries across 396 versions & 1 rubygems

Version Path
trackler-2.2.1.139 tracks/ruby/exercises/house/.meta/solutions/house.rb
trackler-2.2.1.138 tracks/ruby/exercises/house/.meta/solutions/house.rb
trackler-2.2.1.137 tracks/ruby/exercises/house/.meta/solutions/house.rb
trackler-2.2.1.136 tracks/ruby/exercises/house/.meta/solutions/house.rb
trackler-2.2.1.135 tracks/ruby/exercises/house/.meta/solutions/house.rb
trackler-2.2.1.134 tracks/ruby/exercises/house/.meta/solutions/house.rb
trackler-2.2.1.133 tracks/ruby/exercises/house/.meta/solutions/house.rb
trackler-2.2.1.132 tracks/ruby/exercises/house/.meta/solutions/house.rb
trackler-2.2.1.131 tracks/ruby/exercises/house/.meta/solutions/house.rb
trackler-2.2.1.130 tracks/ruby/exercises/house/.meta/solutions/house.rb
trackler-2.2.1.129 tracks/ruby/exercises/house/.meta/solutions/house.rb
trackler-2.2.1.128 tracks/ruby/exercises/house/.meta/solutions/house.rb
trackler-2.2.1.127 tracks/ruby/exercises/house/.meta/solutions/house.rb
trackler-2.2.1.126 tracks/ruby/exercises/house/.meta/solutions/house.rb
trackler-2.2.1.125 tracks/ruby/exercises/house/.meta/solutions/house.rb
trackler-2.2.1.124 tracks/ruby/exercises/house/.meta/solutions/house.rb
trackler-2.2.1.123 tracks/ruby/exercises/house/.meta/solutions/house.rb
trackler-2.2.1.122 tracks/ruby/exercises/house/.meta/solutions/house.rb
trackler-2.2.1.121 tracks/ruby/exercises/house/.meta/solutions/house.rb
trackler-2.2.1.120 tracks/ruby/exercises/house/.meta/solutions/house.rb