Sha256: c797e4773457e9082b669c66c376e0c703dc97bc4eb1d033c3c99eef209aa73a
Contents?: true
Size: 811 Bytes
Versions: 11
Compression:
Stored size: 811 Bytes
Contents
module Gnip module GnipStream class JsonDataBuffer attr_accessor :split_pattern, :check_pattern def initialize(split_pattern, check_pattern) @split_pattern = split_pattern @check_pattern = check_pattern @buffer = "" end def process(chunk) @buffer.concat(chunk) end def complete_entries entries = [] while @buffer =~ check_pattern new_line = @buffer[@buffer.size - 2..@buffer.size - 1] == "\r\n" activities = @buffer.split(split_pattern) entries << activities.shift @buffer = activities.join(split_pattern) @buffer = @buffer + "\r\n" if @buffer.size > 0 && new_line end entries.select{ |entry| entry.size > 0 } end end end end
Version data entries
11 entries across 11 versions & 1 rubygems