Module: CMDx::Coercions::Integer
Overview
Converts various input types to Integer format
Handles conversion from strings, numbers, and other values to integers using Ruby’s Integer() method. Raises CoercionError for values that cannot be converted to integers.
Instance Method Summary collapse
-
#call(value, options = {}) ⇒ Integer
Converts a value to an Integer.
Instance Method Details
#call(value, options = {}) ⇒ Integer
Converts a value to an Integer
39 40 41 42 43 44 |
# File 'lib/cmdx/coercions/integer.rb', line 39 def call(value, = {}) Integer(value) rescue ArgumentError, FloatDomainError, RangeError, TypeError type = Locale.t("cmdx.types.integer") raise CoercionError, Locale.t("cmdx.coercions.into_an", type:) end |