Class: PeriodicCalculations::QueryOptions
- Inherits:
-
Object
- Object
- PeriodicCalculations::QueryOptions
- Defined in:
- lib/periodic_calculations/query_options.rb
Constant Summary collapse
- OPERATION =
[:count, :max, :min, :sum, :avg]
- INTERVAL_UNIT =
[:day, :week, :month, :year]
Instance Attribute Summary collapse
-
#cumulative ⇒ Object
readonly
Returns the value of attribute cumulative.
-
#interval_unit ⇒ Object
readonly
Returns the value of attribute interval_unit.
-
#operation ⇒ Object
readonly
Returns the value of attribute operation.
-
#target_column ⇒ Object
readonly
Returns the value of attribute target_column.
-
#timestamp_column ⇒ Object
readonly
Returns the value of attribute timestamp_column.
-
#timezone_offset ⇒ Object
readonly
Returns the value of attribute timezone_offset.
-
#window_end ⇒ Object
readonly
Returns the value of attribute window_end.
-
#window_start ⇒ Object
readonly
Returns the value of attribute window_start.
Instance Method Summary collapse
-
#initialize(operation, column_name, window_start, window_end, options = {}) ⇒ QueryOptions
constructor
A new instance of QueryOptions.
Constructor Details
#initialize(operation, column_name, window_start, window_end, options = {}) ⇒ QueryOptions
Returns a new instance of QueryOptions.
15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/periodic_calculations/query_options.rb', line 15 def initialize(operation, column_name, window_start, window_end, = {}) @operation = operation @target_column = column_name @timestamp_column = [:timestamp_column] || :created_at @window_start = window_start @window_end = window_end @interval_unit = [:interval_unit] || :day @cumulative = !![:cumulative] @timezone_offset = Time.now.in_time_zone.utc_offset validate! end |
Instance Attribute Details
#cumulative ⇒ Object (readonly)
Returns the value of attribute cumulative.
6 7 8 |
# File 'lib/periodic_calculations/query_options.rb', line 6 def cumulative @cumulative end |
#interval_unit ⇒ Object (readonly)
Returns the value of attribute interval_unit.
6 7 8 |
# File 'lib/periodic_calculations/query_options.rb', line 6 def interval_unit @interval_unit end |
#operation ⇒ Object (readonly)
Returns the value of attribute operation.
6 7 8 |
# File 'lib/periodic_calculations/query_options.rb', line 6 def operation @operation end |
#target_column ⇒ Object (readonly)
Returns the value of attribute target_column.
6 7 8 |
# File 'lib/periodic_calculations/query_options.rb', line 6 def target_column @target_column end |
#timestamp_column ⇒ Object (readonly)
Returns the value of attribute timestamp_column.
6 7 8 |
# File 'lib/periodic_calculations/query_options.rb', line 6 def @timestamp_column end |
#timezone_offset ⇒ Object (readonly)
Returns the value of attribute timezone_offset.
6 7 8 |
# File 'lib/periodic_calculations/query_options.rb', line 6 def timezone_offset @timezone_offset end |
#window_end ⇒ Object (readonly)
Returns the value of attribute window_end.
6 7 8 |
# File 'lib/periodic_calculations/query_options.rb', line 6 def window_end @window_end end |
#window_start ⇒ Object (readonly)
Returns the value of attribute window_start.
6 7 8 |
# File 'lib/periodic_calculations/query_options.rb', line 6 def window_start @window_start end |