Sha256: 03bafa17a673787ca1bdacdd2cb46c4e957576aa8026b5a96698ee65b303c760

Contents?: true

Size: 361 Bytes

Versions: 26

Compression:

Stored size: 361 Bytes

Contents

module ApiResource

  module Typecast

    module FloatTypecaster

      def self.from_api(value)
        return value.to_f if value.respond_to?(:to_f)
        # Special case for true to return 1.0
        return 1.0 if value.class == TrueClass
        return value.to_s.to_f
      end

      def self.to_api(value)
        value
      end

    end

  end

end

Version data entries

26 entries across 26 versions & 1 rubygems

Version Path
api_resource-0.6.25 lib/api_resource/typecasters/float_typecaster.rb
api_resource-0.6.24 lib/api_resource/typecasters/float_typecaster.rb
api_resource-0.6.23 lib/api_resource/typecasters/float_typecaster.rb
api_resource-0.6.22 lib/api_resource/typecasters/float_typecaster.rb
api_resource-0.6.21 lib/api_resource/typecasters/float_typecaster.rb
api_resource-0.6.20 lib/api_resource/typecasters/float_typecaster.rb
api_resource-0.6.19 lib/api_resource/typecasters/float_typecaster.rb
api_resource-0.6.18 lib/api_resource/typecasters/float_typecaster.rb
api_resource-0.6.17 lib/api_resource/typecasters/float_typecaster.rb
api_resource-0.6.16 lib/api_resource/typecasters/float_typecaster.rb
api_resource-0.6.15 lib/api_resource/typecasters/float_typecaster.rb
api_resource-0.6.14 lib/api_resource/typecasters/float_typecaster.rb
api_resource-0.6.13 lib/api_resource/typecasters/float_typecaster.rb
api_resource-0.6.12 lib/api_resource/typecasters/float_typecaster.rb
api_resource-0.6.11 lib/api_resource/typecasters/float_typecaster.rb
api_resource-0.6.9 lib/api_resource/typecasters/float_typecaster.rb
api_resource-0.6.10 lib/api_resource/typecasters/float_typecaster.rb
api_resource-0.6.8 lib/api_resource/typecasters/float_typecaster.rb
api_resource-0.6.7 lib/api_resource/typecasters/float_typecaster.rb
api_resource-0.6.6 lib/api_resource/typecasters/float_typecaster.rb