Sha256: 124d787df45a47d222eb4a3bd2aaaa135b71020aef2b26b02847c37b4ace476e

Contents?: true

Size: 457 Bytes

Versions: 1

Compression:

Stored size: 457 Bytes

Contents

# frozen_string_literal: true

module TJSON
  class DataType
    # Boolean Value
    class Boolean < Scalar
      def tag
        "b"
      end

      def decode(value)
        raise TJSON::TypeError, "'null' is expressly disallowed in TJSON" if value.nil?
        raise TJSON::TypeError, "not a boolean value: #{value.inspect}" unless [true, false].include?(value)
        value
      end

      def encode(value)
        value
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

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