Sha256: 96fa4a0283ea7de251760dc122068df58d0f2c915a8fdf73f796b1f013aa4551

Contents?: true

Size: 925 Bytes

Versions: 1

Compression:

Stored size: 925 Bytes

Contents

require_relative 'temporal_operator'

module ConceptQL
  module Operators
    class During < TemporalOperator
      desc <<-EOF
Compares all results on a person-by-person basis between the left hand results (LHR) and the right hand resuls (RHR).
For any result in the LHR whose start_date and end_date occur within the start_date and end_date of a RHR row, that result is passed through.
All other results are discarded, including all results in the RHR.
      EOF

      def where_clause
        if inclusive?
          Sequel.expr(Sequel.expr(Proc.new { r__start_date <= l__start_date}).&(Sequel.expr( Proc.new { l__start_date <= r__end_date })))
            .|(Sequel.expr(Proc.new { r__start_date <= l__end_date}).&(Sequel.expr( Proc.new { l__end_date <= r__end_date })))
        else
          [Proc.new { r__start_date <= l__start_date}, Proc.new { l__end_date <= r__end_date }]
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

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