Method: Highway::Steps::Types::Number#typecheck
- Defined in:
- lib/highway/steps/types/number.rb
#typecheck(value) ⇒ Integer, ...
Typecheck and coerce a value if possible.
This method returns a typechecked and coerced value or nil if value has invalid type and can’t be coerced.
26 27 28 29 30 31 32 |
# File 'lib/highway/steps/types/number.rb', line 26 def typecheck(value) case value when ::Numeric then value when ::String && value.to_i.to_s == value then value.to_i when ::String && value.to_f.to_s == value then value.to_f end end |