Sha256: 9693f2a0e8630637cbbac986b61ade7d214e632fabc2ba6d6d1c972a711fa9b4

Contents?: true

Size: 319 Bytes

Versions: 7

Compression:

Stored size: 319 Bytes

Contents

# frozen_string_literal: true

# @api public
# @since 0.1.0
SmartCore::Types::Value.define_type(:Numeric) do |type|
  type.define_checker do |value|
    value.is_a?(::Numeric)
  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/numeric.rb
smart_types-0.1.0.alpha5 lib/smart_core/types/value/numeric.rb
smart_types-0.1.0.alpha4 lib/smart_core/types/value/numeric.rb
smart_types-0.1.0.alpha3 lib/smart_core/types/value/numeric.rb
smart_types-0.1.0.alpha2 lib/smart_core/types/value/numeric.rb
smart_types-0.1.0.alpha lib/smart_core/types/value/numeric.rb
smart_types-0.0.0 lib/smart_core/types/value/numeric.rb