lib/picky/query/combinator.rb in picky-0.3.0 vs lib/picky/query/combinator.rb in picky-0.9.0
- old
+ new
@@ -29,26 +29,32 @@
#
def possible_combinations_for token
token.similar? ? similar_possible_for(token) : possible_for(token)
end
- # TODO Break apart.
- #
+ #
+ #
def similar_possible_for token
# Get as many similar tokens as necessary
#
+ tokens = similar_tokens_for token
+ # possible combinations
+ #
+ inject_possible_for tokens
+ end
+ def similar_tokens_for token
text = token.text
- tokens = categories.inject([]) do |result, category|
+ categories.inject([]) do |result, category|
next_token = token
# TODO adjust either this or the amount of similar in index
#
while next_token = next_token.next(category)
result << next_token if next_token && next_token.text != text
end
result
end
- # possible combinations
- #
+ end
+ def inject_possible_for tokens
tokens.inject([]) do |result, token|
possible = possible_categories token
result + possible_for(token, possible)
end
end
\ No newline at end of file