Sha256: 9538579b9f260a0e904ec18a8cdfb4b29831fd4c0ccebcf3c64e6339b0ea280b
Contents?: true
Size: 498 Bytes
Versions: 2
Compression:
Stored size: 498 Bytes
Contents
# frozen_string_literal: true # @api public # @since 0.1.0 SmartCore::Types::Value.define_type(:Float) do |type| type.define_checker do |value| value.is_a?(::Float) end type.define_caster do |value| begin ::Kernel.Float(value) rescue ::TypeError, ::ArgumentError begin ::Kernel.Float(value.to_f) rescue ::NoMethodError, ::TypeError, ::ArgumentError raise(SmartCore::Types::TypeCastingError, 'Non-castable to Float') end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
smart_types-0.2.0 | lib/smart_core/types/value/float.rb |
smart_types-0.1.0 | lib/smart_core/types/value/float.rb |