Class: KQL::Query
- Inherits:
-
Object
- Object
- KQL::Query
- Defined in:
- lib/kql/query.rb
Direct Known Subclasses
Defined Under Namespace
Classes: Context, SelectedNode, TopContext
Instance Attribute Summary collapse
-
#alternatives ⇒ Object
readonly
Returns the value of attribute alternatives.
Instance Method Summary collapse
- #==(other) ⇒ Object
- #execute(document) ⇒ Object
-
#initialize(alternatives) ⇒ Query
constructor
A new instance of Query.
Constructor Details
#initialize(alternatives) ⇒ Query
Returns a new instance of Query.
5 6 7 |
# File 'lib/kql/query.rb', line 5 def initialize(alternatives) @alternatives = alternatives end |
Instance Attribute Details
#alternatives ⇒ Object (readonly)
Returns the value of attribute alternatives.
3 4 5 |
# File 'lib/kql/query.rb', line 3 def alternatives @alternatives end |
Instance Method Details
#==(other) ⇒ Object
9 10 11 12 13 |
# File 'lib/kql/query.rb', line 9 def ==(other) return false unless other.is_a?(Query) other.alternatives == alternatives end |
#execute(document) ⇒ Object
15 16 17 18 19 20 21 |
# File 'lib/kql/query.rb', line 15 def execute(document) alternatives.flat_map do |alt| alt.execute(TopContext.new(document)) .nodes .uniq { |n| n.__id__ } end end |