Sha256: e1cd7abcf031788de40df4a3e04f2022e7f0b216a72e545598077b843020d60e

Contents?: true

Size: 376 Bytes

Versions: 2

Compression:

Stored size: 376 Bytes

Contents

# frozen_string_literal: true

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

      def convert(float)
        raise TJSON::TypeError, "expected Float, got #{float.class}" unless float.is_a?(::Numeric)
        float.to_f
      end

      def generate(float)
        float.to_f
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
tjson-0.3.0 lib/tjson/datatype/float.rb
tjson-0.2.0 lib/tjson/datatype/float.rb