Sha256: bfcb56c15744b2d0263884f999cb8d5516a766c33359ea652135a66a74d78184
Contents?: true
Size: 605 Bytes
Versions: 15
Compression:
Stored size: 605 Bytes
Contents
# frozen_string_literal: true module Shipit class LineBuffer SEPARATOR = "\n" def initialize(queue = "") @queue = queue.dup end def buffer(text, &block) @queue << text whole_lines.each(&block).tap { flush } end def empty? @queue.empty? end private def whole_lines whole? ? lines : lines[0..-2] end def flush whole? ? clear : @queue = lines.last end def whole? @queue.end_with?(SEPARATOR) end def lines @queue.split(SEPARATOR) end def clear @queue.clear end end end
Version data entries
15 entries across 15 versions & 1 rubygems