Class: Picky::Query::Tokens::Or

Inherits:
Picky::Query::Tokens show all
Defined in:
lib/picky/query/or.rb

Overview

This is a combination of multiple (already processed) tokens, combined using the OR character, usually | (pipe).

It pretends to be a single token and answers to all messages a token would answer to.

Instance Attribute Summary

Attributes inherited from Picky::Query::Tokens

#ignore_unassigned, #tokens

Instance Method Summary collapse

Methods inherited from Picky::Query::Tokens

#+, #==, #original, #originals, #partialize_last, #possible_combinations_in, processed, #symbolize, #texts, #to_s

Constructor Details

#initialize(processed_tokens) ⇒ Or

Returns a new instance of Or.



15
16
17
# File 'lib/picky/query/or.rb', line 15

def initialize processed_tokens
  @tokens = processed_tokens
end

Instance Method Details

#possible_combinations(categories) ⇒ Object

TODO



21
22
23
24
25
26
# File 'lib/picky/query/or.rb', line 21

def possible_combinations categories
  combinations = @tokens.inject([]) do |result, token|
    result + token.possible_combinations(categories)
  end
  combinations.empty? && combinations || [Query::Combination::Or.new(combinations)]
end

#symbolize!Object



28
29
30
# File 'lib/picky/query/or.rb', line 28

def symbolize!
  @tokens.symbolize
end