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