Class: ProductGroupSearch::NumberField
- Inherits:
-
BaseField
- Object
- BaseField
- ProductGroupSearch::NumberField
show all
- Defined in:
- lib/nimbleshop/product_group_search/number_field.rb
Instance Attribute Summary
Attributes inherited from BaseField
#condition
Instance Method Summary
collapse
Methods inherited from BaseField
#initialize, #valid_operator?, #where
Instance Method Details
#coerced_value ⇒ Object
9
10
11
|
# File 'lib/nimbleshop/product_group_search/number_field.rb', line 9
def coerced_value
value.try(:to_f)
end
|
#valid_operators ⇒ Object
13
14
15
|
# File 'lib/nimbleshop/product_group_search/number_field.rb', line 13
def valid_operators
%w(eq lt gt lteq gteq)
end
|
#valid_value_data_type? ⇒ Boolean
5
6
7
|
# File 'lib/nimbleshop/product_group_search/number_field.rb', line 5
def valid_value_data_type?
value && value.to_s.try(:match, /\A[+-]?\d+?(\.\d+)?\Z/).present?
end
|