Class: LIVR::Rules::Numeric::Decimal

Inherits:
LIVR::Rule show all
Defined in:
lib/livr/rules/numeric.rb

Instance Method Summary collapse

Methods inherited from LIVR::Rule

#initialize

Constructor Details

This class inherits a constructor from LIVR::Rule

Instance Method Details

#call(value, user_data, field_results) ⇒ Object


37
38
39
40
41
42
43
44
45
46
# File 'lib/livr/rules/numeric.rb', line 37

def call(value, user_data, field_results)
  return if is_no_value(value)
  return 'FORMAT_ERROR' if !is_primitive(value)

  value_int = Float(value.to_s) rescue nil
  return "NOT_DECIMAL" if value_int.nil?

  field_results << value_int
  return
end