Sha256: d9c290854f3745e1271e2539db86f4fbcd1020f761ce697238e3e52924707001

Contents?: true

Size: 903 Bytes

Versions: 1

Compression:

Stored size: 903 Bytes

Contents

require_relative 'binary_operator_operator'

module ConceptQL
  module Operators
    # 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 }
    class TemporalOperator < BinaryOperatorOperator
      reset_categories
      category %w(Temporal Relative)

      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

      def inclusive?
        options[:inclusive]
      end

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

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


Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
conceptql-0.2.0 lib/conceptql/operators/temporal_operator.rb