Class: LIVR::Rules::Numeric::MinNumber
- Inherits:
-
LIVR::Rule
- Object
- LIVR::Rule
- LIVR::Rules::Numeric::MinNumber
- Defined in:
- lib/livr/rules/numeric.rb
Instance Method Summary collapse
- #call(value, user_data, field_results) ⇒ Object
-
#initialize(min_number) ⇒ MinNumber
constructor
A new instance of MinNumber.
Constructor Details
#initialize(min_number) ⇒ MinNumber
Returns a new instance of MinNumber.
88 89 90 |
# File 'lib/livr/rules/numeric.rb', line 88 def initialize(min_number) @min_number = min_number end |
Instance Method Details
#call(value, user_data, field_results) ⇒ Object
92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 |
# File 'lib/livr/rules/numeric.rb', line 92 def call(value, user_data, field_results) return if is_no_value(value) return 'FORMAT_ERROR' if !is_primitive(value) value = Float(value.to_s) rescue nil if value.nil? return "NOT_NUMBER" end if value < @min_number return "TOO_LOW" else field_results << value return end end |