Sha256: df7f5c73480ce57de7afafa3610eac672ca8e8b690772f49153c808a5b840ced

Contents?: true

Size: 691 Bytes

Versions: 4

Compression:

Stored size: 691 Bytes

Contents

class Wankel
  class StreamEncoder
  
    def value(val)
      case val
      when NilClass
        null
      when TrueClass, FalseClass
        boolean(val)
      when Numeric
        number(val)
      when String
        string(val)
      when Array
        array_open
        val.each {|v| value(v) }
        array_close
      when Hash
        map_open
        val.each {|k, v| string(k.to_s); value(v) }
        map_close
      else
        case @options[:mode]
        when :strict
          raise Wankel::EncodeError, "Unkown JSON type #{val.class}"
        when :nil
          null
        else
          value(val.send(@options[:mode]))
        end
      end
    end
    
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
wankel-0.6.2.1 lib/wankel/stream_encoder.rb
wankel-0.6.2 lib/wankel/stream_encoder.rb
wankel-0.6.1 lib/wankel/stream_encoder.rb
wankel-0.6.0 lib/wankel/stream_encoder.rb