Sha256: 20995825e192901ab112b0e6f7a41136d9582b552149db5dcb9790310bb4747d

Contents?: true

Size: 311 Bytes

Versions: 5

Compression:

Stored size: 311 Bytes

Contents

module Soulmate
  module Helpers

    def prefixes_for_phrase(phrase)
      words = normalize(phrase).split(' ')
      words.map do |w|
        (MIN_COMPLETE-1..(w.length-1)).map{ |l| w[0..l] }
      end.flatten
    end

    def normalize(str)
      str.downcase.gsub(/[^a-z0-9 ]/i, '').strip
    end

  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
soulmate-0.0.4 lib/soulmate/helpers.rb
soulmate-0.0.3 lib/soulmate/helpers.rb
soulmate-0.0.2 lib/soulmate/helpers.rb
soulmate-0.0.1 lib/soulmate/helpers.rb
soulmate-0.0.0 lib/soulmate/helpers.rb