Class: Transit::Unmarshaler::Json Private

Inherits:
Object
  • Object
show all
Defined in:
lib/transit/unmarshaler/cruby/json.rb

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Defined Under Namespace

Classes: ParseHandler

Instance Method Summary collapse

Constructor Details

#initialize(io, opts) ⇒ Json

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Json.



38
39
40
41
42
# File 'lib/transit/unmarshaler/cruby/json.rb', line 38

def initialize(io, opts)
  @io = io
  @decoder = Transit::Decoder.new(opts)
  @parse_handler = ParseHandler.new
end

Instance Method Details

#readObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

See Also:



45
46
47
48
49
50
51
52
# File 'lib/transit/unmarshaler/cruby/json.rb', line 45

def read
  if block_given?
    @parse_handler.each {|v| yield @decoder.decode(v)}
  else
    @parse_handler.each {|v| return @decoder.decode(v)}
  end
  Oj.sc_parse(@parse_handler, @io) {|_stack|}
end