Class: ConceptQL::Nodes::TemporalNode

Inherits:
BinaryOperatorNode show all
Defined in:
lib/conceptql/nodes/temporal_node.rb

Overview

Base class for all temporal nodes

Subclasses must implement the where_clause method which should probably return a proc that can be executed as a Sequel “virtual row” e.g. Proc.new { l.end_date < r.start_date }

Direct Known Subclasses

After, Before, During, Equal, StartedBy

Constant Summary

Constants inherited from Node

Node::COLUMNS

Instance Attribute Summary

Attributes inherited from Node

#values

Instance Method Summary collapse

Methods inherited from BinaryOperatorNode

#children, #display_name, #graph_it

Methods inherited from Node

#arguments, #children, #columns, #evaluate, #initialize, #select_it, #sql, #stream, #types

Constructor Details

This class inherits a constructor from ConceptQL::Nodes::Node

Instance Method Details

#inclusive?Boolean

Returns:

  • (Boolean)


18
19
20
# File 'lib/conceptql/nodes/temporal_node.rb', line 18

def inclusive?
  options[:inclusive]
end

#left_stream(db) ⇒ Object



22
23
24
# File 'lib/conceptql/nodes/temporal_node.rb', line 22

def left_stream(db)
  Sequel.expr(left.evaluate(db)).as(:l)
end

#query(db) ⇒ Object



11
12
13
14
15
16
# File 'lib/conceptql/nodes/temporal_node.rb', line 11

def query(db)
  db.from(db.from(left_stream(db))
            .join(right_stream(db), l__person_id: :r__person_id)
            .where(where_clause)
            .select_all(:l))
end

#right_stream(db) ⇒ Object



26
27
28
# File 'lib/conceptql/nodes/temporal_node.rb', line 26

def right_stream(db)
  Sequel.expr(right.evaluate(db)).as(:r)
end