class LIVR::Rules::Numeric::MaxNumber
Public Class Methods
new(max_number)
click to toggle source
# File lib/livr/rules/numeric.rb, line 65 def initialize(max_number) @max_number = max_number end
Public Instance Methods
call(value, user_data, field_results)
click to toggle source
# File lib/livr/rules/numeric.rb, line 69 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 > @max_number return "TOO_HIGH" else field_results << value return end end