class Transit::Reader
Transit::Reader
converts incoming transit data into appropriate values/objects in Ruby. @see github.com/cognitect/transit-format
Public Class Methods
new(format, io, opts={})
click to toggle source
@param [Symbol] format required any of :msgpack, :json, :json_verbose @param [IO] io required @param [Hash] opts optional Creates a new Reader
configured to read from io
, expecting format
(:json
, :msgpack
).
Use opts to register custom read handlers, associating each one with its tag.
@example
json_reader = Transit::Reader.new(:json, io) # ^^ reads both :json and :json_verbose formats ^^ msgpack_writer = Transit::Reader.new(:msgpack, io) writer_with_custom_handlers = Transit::Reader.new(:json, io, :handlers => {"point" => PointReadHandler})
# File lib/transit/reader.rb, line 56 def initialize(format, io, opts={}) @reader = case format when :json, :json_verbose Unmarshaler::Json.new(io, opts) else Unmarshaler::MessagePack.new(io, opts) end end