Class: ReportsKit::Reports::FilterTypes::Number
- Defined in:
- lib/reports_kit/reports/filter_types/number.rb
Constant Summary collapse
- DEFAULT_CRITERIA =
{}
Instance Attribute Summary
Attributes inherited from Base
#primary_dimension, #properties, #settings
Instance Method Summary collapse
Methods inherited from Base
#apply_filter, #default_criteria, #initialize
Constructor Details
This class inherits a constructor from ReportsKit::Reports::FilterTypes::Base
Instance Method Details
#apply_conditions(records) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/reports_kit/reports/filter_types/number.rb', line 7 def apply_conditions(records) case criteria[:operator] when '>' records.where(column => (value.to_i...Float::INFINITY)) when '>=' records.where(column => (value.to_i..Float::INFINITY)) when '<' records.where(column => (-Float::INFINITY...value.to_i)) when '<=' records.where(column => (-Float::INFINITY..value.to_i)) when '=' records.where(column => value.to_i) else raise ArgumentError.new("Unsupported operator: '#{criteria[:operator]}'") end end |
#valid? ⇒ Boolean
24 25 26 |
# File 'lib/reports_kit/reports/filter_types/number.rb', line 24 def valid? value.present? end |