Class: ProductGroupSearch::NumberField

Inherits:
BaseField
  • Object
show all
Defined in:
lib/nimbleshop/product_group_search/number_field.rb

Direct Known Subclasses

DateField

Instance Attribute Summary

Attributes inherited from BaseField

#condition

Instance Method Summary collapse

Methods inherited from BaseField

#initialize, #valid_operator?, #where

Constructor Details

This class inherits a constructor from ProductGroupSearch::BaseField

Instance Method Details

#coerced_valueObject



9
10
11
# File 'lib/nimbleshop/product_group_search/number_field.rb', line 9

def coerced_value
  value.try(:to_f)
end

#valid_operatorsObject



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

Returns:

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