Class: Wice::FilterConditionsGeneratorInteger
- Inherits:
-
FilterConditionsGenerator
- Object
- FilterConditionsGenerator
- Wice::FilterConditionsGeneratorInteger
- Defined in:
- lib/filter_conditions_generators.rb
Overview
:nodoc:
Constant Summary collapse
- VALID_NUMBER_RE =
@@handled_type = self
/(\d+)((G|M|K)B?)?/i
Instance Attribute Summary
Attributes inherited from FilterConditionsGenerator
Instance Method Summary collapse
-
#generate_conditions(opts) ⇒ Object
:nodoc:.
Methods inherited from FilterConditionsGenerator
Constructor Details
This class inherits a constructor from Wice::FilterConditionsGenerator
Instance Method Details
#generate_conditions(opts) ⇒ Object
:nodoc:
107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 |
# File 'lib/filter_conditions_generators.rb', line 107 def generate_conditions(opts) #:nodoc: unless opts.kind_of? Hash Wice.log "invalid parameters for the grid integer filter - must be a hash" return false end if !opts[:fr] || !(opts[:fr] =~ VALID_NUMBER_RE) || !opts[:to] || !(opts[:to] =~ VALID_NUMBER_RE) Wice.log "invalid parameters for the grid integer filter - either range limits are not supplied or they are not numeric" return false end from = parse_number(opts[:fr]) to = parse_number(opts[:to]) @criteria = @criteria.where(@field.name.to_sym.gte => from) @criteria = @criteria.where(@field.name.to_sym.lte => to) return true end |