Sha256: ccc4c495bccaf688e02dd3ad0647194204ddea8320a3a064bcde3962152a72ec

Contents?: true

Size: 546 Bytes

Versions: 3

Compression:

Stored size: 546 Bytes

Contents

module TypoGen
  class StartSameSound
    PATTERN_LIST = [
        %w(in im),
        %w(con com),
        %w(clo cro),
        %w(cou coa),
        %w(car cur),
    ].freeze

    def self.create(word)
      typo_list = []

      PATTERN_LIST.each do |pattern|
        pattern.combination(2).each do |from, to|
          if word =~ /^#{from}/
            typo_list << word.sub(/^#{from}/, to)
          elsif word =~ /^#{to}/
            typo_list << word.sub(/^#{to}/, from)
          end
        end
      end

      typo_list
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
typogen-0.2.2 lib/typogen/start_same_sound.rb
typogen-0.2.1 lib/typogen/start_same_sound.rb
typogen-0.2.0 lib/typogen/start_same_sound.rb