def parse(segment, &block)
      @in_rows = true if @row_level == 0
      segment.each_char do |c|
        if @string
          # Inside a string, handling escaping and closure
          if @escape
            @escape = false
          else
            if c == '"'
              @string = false
            elsif c == '\\'
              @escape = true
            end
          end
        else
          # Inside an object
          @obj_close = false
          if @obj_level == @row_level && c == "[" # start of rows
            @in_rows = true
          elsif @obj_level == @row_level && c == "]" # end of rows
            @in_rows = false
          elsif c == "{" # object
            @obj_level += 1
          elsif c == "}" # object end
            @obj_level -= 1
            @obj_close = true
          elsif c == '"'
            @string = true
          end
        end

        # Append data
        if @row_level > 0
          if @obj_level == 0 || (@obj_level == @row_level && !@obj_close)
            @header << c unless @in_rows && (c == ',' || c == ' ' || c == "\n") # skip row whitespace
          else
            @data << c
          end
        else
          @data << c
        end

        # Determine if we need to trigger an event
        if @obj_close && @obj_level == @row_level
          block.call(@data)
          @data = ""
        end
      end
    end
def parse(segment, &block)
      @in_rows = true if @row_level == 0
      segment.each_char do |c|
        if @string
          # Inside a string, handling escaping and closure
          if @escape
            @escape = false
          else
            if c == '"'
              @string = false
            elsif c == '\\'
              @escape = true
            end
          end
        else
          # Inside an object
          @obj_close = false
          if @obj_level == @row_level && c == "[" # start of rows
            @in_rows = true
          elsif @obj_level == @row_level && c == "]" # end of rows
            @in_rows = false
          elsif c == "{" # object
            @obj_level += 1
          elsif c == "}" # object end
            @obj_level -= 1
            @obj_close = true
          elsif c == '"'
            @string = true
          end
        end

        # Append data
        if @row_level > 0
          if @obj_level == 0 || (@obj_level == @row_level && !@obj_close)
            @header << c unless @in_rows && (c == ',' || c == ' ' || c == "\n") # skip row whitespace
          else
            @data << c
          end
        else
          @data << c
        end

        # Determine if we need to trigger an event
        if @obj_close && @obj_level == @row_level
          block.call(@data)
          @data = ""
        end
      end
    end
Instantiate a new StreamRowParser with the mode set according to the type of data.
 The supported modes are:

  * `:array` - objects are contianed in a data array, the default.
  * `:feed` - each row of the stream is an object, like in continuous changes feeds.