Class: ConceptQL::Operators::TimeWindow

Inherits:
Operator
  • Object
show all
Defined in:
lib/conceptql/operators/time_window.rb

Overview

A TimeWindow adjusts the start_date and end_date the incoming stream by the values specified in the start and end arguments.

Start and end take the format of ([+-]d*)+. For example: ‘d’ => adjust date by one day. 2012-10-07 => 2012-10-08 ‘m’ => adjust date by one month. 2012-10-07 => 2012-11-07 ‘y’ => adjust date by one year. 2012-10-07 => 2013-10-07 ‘1y’ => adjust date by one year. 2012-10-07 => 2013-10-07 ‘1d1y’ => adjust date by one day and one year. 2012-10-07 => 2013-10-08 ‘-1d’ => adjust date by negative one day. 2012-10-07 => 2012-10-06 ‘-1d1y’ => adjust date by negative one day and positive one year. 2012-10-07 => 2013-10-06 ”, ‘0’, nil => don’t adjust date at all

Both start and end arguments must be provided, but if you do not wish to adjust a date just pass ”, ‘0’, or nil as that argument. E.g.: start: ‘d’, end: ” # Only adjust start_date by positive 1 day and leave end_date uneffected

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 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

#query(db) ⇒ Object



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

def query(db)
  db.extension :date_arithmetic
  db.from(stream.evaluate(db))
end