Class: Redis::Commands::Search::PredicateCollection
- Inherits:
-
Object
- Object
- Redis::Commands::Search::PredicateCollection
- Defined in:
- lib/redis/commands/modules/search/query.rb
Overview
An ordered collection of predicates joined with AND (a space) or OR (+ | +).
Instance Attribute Summary collapse
- #predicates ⇒ Symbol, Array<Predicate, PredicateCollection> readonly
- #type ⇒ Symbol, Array<Predicate, PredicateCollection> readonly
Instance Method Summary collapse
-
#add(predicate) ⇒ Array
Add a predicate (or nested collection) to this collection.
-
#initialize(type) ⇒ PredicateCollection
constructor
A new instance of PredicateCollection.
-
#to_s ⇒ String
The parenthesised, joined query-string fragment.
Constructor Details
#initialize(type) ⇒ PredicateCollection
Returns a new instance of PredicateCollection.
717 718 719 720 |
# File 'lib/redis/commands/modules/search/query.rb', line 717 def initialize(type) @type = type @predicates = [] end |
Instance Attribute Details
#predicates ⇒ Symbol, Array<Predicate, PredicateCollection> (readonly)
714 715 716 |
# File 'lib/redis/commands/modules/search/query.rb', line 714 def predicates @predicates end |
#type ⇒ Symbol, Array<Predicate, PredicateCollection> (readonly)
714 715 716 |
# File 'lib/redis/commands/modules/search/query.rb', line 714 def type @type end |
Instance Method Details
#add(predicate) ⇒ Array
Add a predicate (or nested collection) to this collection.
726 727 728 |
# File 'lib/redis/commands/modules/search/query.rb', line 726 def add(predicate) @predicates << predicate end |
#to_s ⇒ String
Returns the parenthesised, joined query-string fragment.
731 732 733 734 |
# File 'lib/redis/commands/modules/search/query.rb', line 731 def to_s joiner = @type == :or ? ' | ' : ' ' "(#{@predicates.join(joiner)})" end |