Module: CMDx::Coercions::Float
Overview
Converts various input types to Float format
Handles conversion from numeric strings, integers, and other numeric types that can be converted to floats using Ruby’s Float() method.
Instance Method Summary collapse
-
#call(value, options = {}) ⇒ Float
Converts a value to a Float.
Instance Method Details
#call(value, options = {}) ⇒ Float
Converts a value to a Float
35 36 37 38 39 40 |
# File 'lib/cmdx/coercions/float.rb', line 35 def call(value, = {}) Float(value) rescue ArgumentError, RangeError, TypeError type = Locale.t("cmdx.types.float") raise CoercionError, Locale.t("cmdx.coercions.into_a", type:) end |