Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Simplified building of result string
  • Loading branch information
kerryb committed Jul 15, 2009
1 parent 8a5667d commit 45d5728
Showing 1 changed file with 1 addition and 12 deletions.
13 changes: 1 addition & 12 deletions 1.rb
Expand Up @@ -8,20 +8,9 @@ module StringExtensions
REGEX_TO_SPLIT_ALONG_WHITESPACES = /\s+/

def phrases(number)
list_of_keywords = ""
count = 0
strings = split(REGEX_TO_SPLIT_ALONG_WHITESPACES)
all_strings = single_double_triple_words(strings)
size = all_strings.size
all_strings.each do |phrase|
break if count == number
list_of_keywords += "'" + phrase + "'"
count += 1
if (count < size && count < number)
list_of_keywords += ", "
end
end
return list_of_keywords
all_strings[0, number].map {|s| "'#{s}'"}.join(', ')
end

private
Expand Down

0 comments on commit 45d5728

Please sign in to comment.