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.0.6.20 tracks/ruby/exercises/house/example.rb
trackler-2.0.6.19 tracks/ruby/exercises/house/example.rb
trackler-2.0.6.18 tracks/ruby/exercises/house/example.rb
trackler-2.0.6.17 tracks/ruby/exercises/house/example.rb
trackler-2.0.6.16 tracks/ruby/exercises/house/example.rb
trackler-2.0.6.15 tracks/ruby/exercises/house/example.rb
trackler-2.0.6.14 tracks/ruby/exercises/house/example.rb
trackler-2.0.6.13 tracks/ruby/exercises/house/example.rb
trackler-2.0.6.12 tracks/ruby/exercises/house/example.rb
trackler-2.0.6.11 tracks/ruby/exercises/house/example.rb
trackler-2.0.6.10 tracks/ruby/exercises/house/example.rb
trackler-2.0.6.9 tracks/ruby/exercises/house/example.rb
trackler-2.0.6.8 tracks/ruby/exercises/house/example.rb
trackler-2.0.6.7 tracks/ruby/exercises/house/example.rb
trackler-2.0.6.6 tracks/ruby/exercises/house/example.rb
trackler-2.0.6.5 tracks/ruby/exercises/house/example.rb
trackler-2.0.6.4 tracks/ruby/exercises/house/example.rb
trackler-2.0.6.3 tracks/ruby/exercises/house/example.rb
trackler-2.0.6.2 tracks/ruby/exercises/house/example.rb
trackler-2.0.6.1 tracks/ruby/exercises/house/example.rb