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.0.5 tracks/ruby/exercises/house/example.rb
trackler-2.0.0.4 tracks/ruby/exercises/house/example.rb
trackler-2.0.0.3 tracks/ruby/exercises/house/example.rb
trackler-2.0.0.2 tracks/ruby/exercises/house/example.rb
trackler-2.0.0.1 tracks/ruby/exercises/house/example.rb
trackler-2.0.0.0 tracks/ruby/exercises/house/example.rb
trackler-1.0.4.1 tracks/ruby/exercises/house/example.rb
trackler-1.0.4.0 tracks/ruby/exercises/house/example.rb
trackler-1.0.3.0 tracks/ruby/exercises/house/example.rb
trackler-1.0.2.1 tracks/ruby/exercises/house/example.rb
trackler-1.0.2.0 tracks/ruby/exercises/house/example.rb
trackler-1.0.1.2 tracks/ruby/exercises/house/example.rb
trackler-1.0.1.1 tracks/ruby/exercises/house/example.rb
trackler-1.0.1.0 tracks/ruby/exercises/house/example.rb
trackler-1.0.0.1 tracks/ruby/exercises/house/example.rb
trackler-1.0.0 tracks/ruby/exercises/house/example.rb