Sha256: 74639e94cc74704124ecf52c9d54a3c32810cfd3a5b6669e61216ad7bc4e5eeb
Contents?: true
Size: 738 Bytes
Versions: 2
Compression:
Stored size: 738 Bytes
Contents
# frozen_string_literal: true module TJSON class DataType # TJSON objects class Object < NonScalar def tag "O" end def convert(obj) raise TJSON::TypeError, "expected TJSON::Object, got #{obj.class}" unless obj.is_a?(TJSON::Object) # Objects handle their own member conversions obj end def generate(obj) members = obj.map do |k, v| raise TypeError, "expected String for key, got #{k.class}" unless k.is_a?(::String) type = TJSON::DataType.identify_type(v) ["#{k}:#{type.tag}", TJSON::DataType.generate(v)] end Hash[members] end def inspect "#<#{self.class}>" end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
tjson-0.3.0 | lib/tjson/datatype/object.rb |
tjson-0.2.0 | lib/tjson/datatype/object.rb |