Sha256: 8040022c4c70d3d286fc86653c5c3746bf5af3d7564a001215f14657b3423ff1
Contents?: true
Size: 558 Bytes
Versions: 6
Compression:
Stored size: 558 Bytes
Contents
# frozen_string_literal: true using SmartCore::Ext::BasicObjectAsObject # @api public # @since 0.1.0 # @version 0.3.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
6 entries across 6 versions & 1 rubygems