module OandaAPI::Streaming::Adapters::Yajl

Can be used if the ruby engine (`RUBY_ENGINE`) is NOT jruby. Uses the {github.com/brianmario/yajl-ruby yajl-ruby} gem. Handles streams of multiple JSON objects that may or may not be delimited with whitespace.

Public Instance Methods

parse(string) click to toggle source

Deserializes a stream of JSON objects. @param [String] string serialized json. @return [Array<Hash>] an array of hashes.

# File lib/oanda_api/streaming/adapters/yajl.rb, line 15
def parse(string)
  results = []
  parser.parse(string) { |hash| results << hash }
  results
end

Private Instance Methods

parser() click to toggle source

@private Memoized parser instance.

# File lib/oanda_api/streaming/adapters/yajl.rb, line 25
def parser
  @parser ||= ::Yajl::Parser.new(symbolize_keys: true)
end