Class: Transit::Reader
- Inherits:
-
Object
- Object
- Transit::Reader
- Extended by:
- Forwardable
- Defined in:
- lib/transit/reader.rb
Overview
Transit::Reader converts incoming transit data into appropriate values/objects in Ruby.
Instance Method Summary collapse
-
#initialize(format, io, opts = {}) ⇒ Reader
constructor
Creates a new Reader configured to read from io, expecting format (:json, :msgpack).
-
#read ⇒ Object
Reads transit values from an IO (file, stream, etc), and converts each one to the appropriate Ruby object.
Constructor Details
#initialize(format, io, opts = {}) ⇒ Reader
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.
56 57 58 59 60 61 62 63 |
# 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 |
Instance Method Details
#read ⇒ Object
Reads transit values from an IO (file, stream, etc), and converts each one to the appropriate Ruby object.
With a block, yields each object to the block as it is processed.
Without a block, returns a single object.
36 |
# File 'lib/transit/reader.rb', line 36 def_delegators :@reader, :read |