Sha256: cdf0f998fe3b0df2cafff95408562b1edd6dd0301cf54249a9bc50b20ecb13ca

Contents?: true

Size: 315 Bytes

Versions: 7

Compression:

Stored size: 315 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
      Float(value)
    rescue ::TypeError, ::ArgumentError
      value.to_f
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
smart_types-0.1.0.alpha6 lib/smart_core/types/value/float.rb
smart_types-0.1.0.alpha5 lib/smart_core/types/value/float.rb
smart_types-0.1.0.alpha4 lib/smart_core/types/value/float.rb
smart_types-0.1.0.alpha3 lib/smart_core/types/value/float.rb
smart_types-0.1.0.alpha2 lib/smart_core/types/value/float.rb
smart_types-0.1.0.alpha lib/smart_core/types/value/float.rb
smart_types-0.0.0 lib/smart_core/types/value/float.rb