Sha256: 6ca66eff04281dd182a95cced1403f68b0eefb30b4906c932d64e1d0361a8d7b
Contents?: true
Size: 968 Bytes
Versions: 3
Compression:
Stored size: 968 Bytes
Contents
require 'forwardable' module Json module Streamer class Aggregator extend Forwardable def_delegators :@aggregator, :pop, :push, :empty? def initialize @aggregator = [] end def get @aggregator end def level @aggregator.size end def key @aggregator.last[:key] unless @aggregator.last.nil? end def key=(k) @aggregator.last[:key] = k end def value @aggregator.last[:value] end def value=(d) if array_level? value << d else value[key] = d end end def key_for_level(level) @aggregator[level - 1][:key] unless @aggregator[level - 1].nil? end def value_for_level(level) @aggregator[level - 1][:key] unless @aggregator[level - 1].nil? end private def array_level? value.is_a?(Array) end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
json-streamer-2.1.0 | lib/json/streamer/aggregator.rb |
json-streamer-2.0.1 | lib/json/streamer/aggregator.rb |
json-streamer-2.0.0 | lib/json/streamer/aggregator.rb |