Class: LIVR::Rules::Numeric::Integer

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


6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/livr/rules/numeric.rb', line 6

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

  value_int = Integer(value.to_s) rescue nil
  if value_int.nil?
    return "NOT_INTEGER"
  end

  field_results << value_int
  return
end