Sha256: 75321308b83af7c45bad443a90fbb3ae0e301f1a40434dda74ba33f3eb386ccd

Contents?: true

Size: 383 Bytes

Versions: 1

Compression:

Stored size: 383 Bytes

Contents

# frozen_string_literal: true

module TJSON
  class DataType
    # Floating point type
    class Float < Scalar
      def tag
        "f"
      end

      def decode(float)
        raise TJSON::TypeError, "not a floating point value: #{float.inspect}" unless float.is_a?(::Numeric)
        float.to_f
      end

      def encode(float)
        float.to_f
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
tjson-0.5.0 lib/tjson/datatype/float.rb