Sha256: 395d224290e6d70c24b4b6a86002336360cd68eaa9fa9af6a619afa0de23b826

Contents?: true

Size: 650 Bytes

Versions: 216

Compression:

Stored size: 650 Bytes

Contents

require 'generator/exercise_case'

class AnagramCase < Generator::ExerciseCase

  def workload
    indent_lines([show_comment, detector, anagram, wanted, assert].compact)
  end

  private

  def indent_lines(code, indent = 2)
    code.join("\n" + ' '*2*indent)
  end

  def show_comment
    "# #{comment}" if respond_to?(:comment)
  end

  def detector
    "detector = Anagram.new('#{subject}')"
  end

  def anagram
    "anagrams = detector.match(#{candidates})"
  end

  def wanted
    "expected = #{expected.sort}"
  end

  def assert
    actual = expected.size > 1 ? 'anagrams.sort' : 'anagrams'
    "assert_equal expected, #{actual}"
  end

end

Version data entries

216 entries across 216 versions & 1 rubygems

Version Path
trackler-2.2.1.119 tracks/ruby/exercises/anagram/.meta/generator/anagram_case.rb
trackler-2.2.1.118 tracks/ruby/exercises/anagram/.meta/generator/anagram_case.rb
trackler-2.2.1.117 tracks/ruby/exercises/anagram/.meta/generator/anagram_case.rb
trackler-2.2.1.116 tracks/ruby/exercises/anagram/.meta/generator/anagram_case.rb
trackler-2.2.1.115 tracks/ruby/exercises/anagram/.meta/generator/anagram_case.rb
trackler-2.2.1.114 tracks/ruby/exercises/anagram/.meta/generator/anagram_case.rb
trackler-2.2.1.113 tracks/ruby/exercises/anagram/.meta/generator/anagram_case.rb
trackler-2.2.1.111 tracks/ruby/exercises/anagram/.meta/generator/anagram_case.rb
trackler-2.2.1.110 tracks/ruby/exercises/anagram/.meta/generator/anagram_case.rb
trackler-2.2.1.109 tracks/ruby/exercises/anagram/.meta/generator/anagram_case.rb
trackler-2.2.1.108 tracks/ruby/exercises/anagram/.meta/generator/anagram_case.rb
trackler-2.2.1.107 tracks/ruby/exercises/anagram/.meta/generator/anagram_case.rb
trackler-2.2.1.106 tracks/ruby/exercises/anagram/.meta/generator/anagram_case.rb
trackler-2.2.1.105 tracks/ruby/exercises/anagram/.meta/generator/anagram_case.rb
trackler-2.2.1.104 tracks/ruby/exercises/anagram/.meta/generator/anagram_case.rb
trackler-2.2.1.103 tracks/ruby/exercises/anagram/.meta/generator/anagram_case.rb
trackler-2.2.1.102 tracks/ruby/exercises/anagram/.meta/generator/anagram_case.rb
trackler-2.2.1.101 tracks/ruby/exercises/anagram/.meta/generator/anagram_case.rb
trackler-2.2.1.100 tracks/ruby/exercises/anagram/.meta/generator/anagram_case.rb
trackler-2.2.1.99 tracks/ruby/exercises/anagram/.meta/generator/anagram_case.rb