Class: ConceptQL::Operators::TemporalOperator

Inherits:
BinaryOperatorOperator show all
Defined in:
lib/conceptql/operators/temporal_operator.rb

Overview

Base class for all temporal operators

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 }

Constant Summary

Constants inherited from Operator

Operator::COLUMNS

Instance Attribute Summary

Attributes inherited from Operator

#arguments, #options, #upstreams, #values

Instance Method Summary collapse

Methods inherited from BinaryOperatorOperator

#display_name, #graph_it, #upstreams

Methods inherited from Operator

#columns, #evaluate, #initialize, #label, #select_it, #set_values, #sql, #stream, #types

Methods included from Metadatable

#allows_many_upstreams, #allows_one_upstream, #argument, #category, #desc, #humanized_class_name, #inherited, #just_class_name, #option, #predominant_types, #preferred_name, #reset_categories, #to_metadata, #types

Constructor Details

This class inherits a constructor from ConceptQL::Operators::Operator

Instance Method Details

#inclusive?Boolean

Returns:

  • (Boolean)


21
22
23
# File 'lib/conceptql/operators/temporal_operator.rb', line 21

def inclusive?
  options[:inclusive]
end

#left_stream(db) ⇒ Object



25
26
27
# File 'lib/conceptql/operators/temporal_operator.rb', line 25

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

#query(db) ⇒ Object



14
15
16
17
18
19
# File 'lib/conceptql/operators/temporal_operator.rb', line 14

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



29
30
31
# File 'lib/conceptql/operators/temporal_operator.rb', line 29

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