Class: Quercle::PredicateSet
- Inherits:
-
Object
- Object
- Quercle::PredicateSet
- Defined in:
- lib/quercle/predicate_set.rb
Instance Attribute Summary collapse
-
#operator ⇒ Object
Returns the value of attribute operator.
-
#predicates ⇒ Object
Returns the value of attribute predicates.
Instance Method Summary collapse
-
#initialize(json) ⇒ PredicateSet
constructor
A new instance of PredicateSet.
- #to_a ⇒ Object
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
#operator ⇒ Object
Returns the value of attribute operator.
3 4 5 |
# File 'lib/quercle/predicate_set.rb', line 3 def operator @operator end |
#predicates ⇒ Object
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_a ⇒ Object
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 |