Class: Quercle::PredicateSet

Inherits:
Object
  • Object
show all
Defined in:
lib/quercle/predicate_set.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(json) ⇒ PredicateSet

Returns a new instance of PredicateSet.



4
5
6
7
8
9
# File 'lib/quercle/predicate_set.rb', line 4

def initialize(json)
  @operator = json['operator']
  @predicates = json['predicates'].collect do |predicate_or_set|
    Quercle.parse(predicate_or_set)
  end
end

Instance Attribute Details

#operatorObject

Returns the value of attribute operator.



3
4
5
# File 'lib/quercle/predicate_set.rb', line 3

def operator
  @operator
end

#predicatesObject

Returns the value of attribute predicates.



3
4
5
# File 'lib/quercle/predicate_set.rb', line 3

def predicates
  @predicates
end

Instance Method Details

#to_aObject



11
12
13
14
15
16
17
18
19
# File 'lib/quercle/predicate_set.rb', line 11

def to_a
  fragments, values = [], []
  predicates.each do |predicate_or_set|
    array = predicate_or_set.to_a
    fragments << array.shift
    values    += array
  end
  ["(#{fragments.join(" #{operator} ")})", *values]
end