class Tailwindcss::Purger::Conveyor

def conditionally_keep(pattern)

def conditionally_keep(pattern)
  keep(pattern) do |match|
    (yield match) ? match.to_s : (break "")
  end
end

def consume(pattern)

def consume(pattern)
  match = pattern.match(@input)
  @input = match.post_match if match
  match
end

def done?

def done?
  @input.empty?
end

def initialize(input, output = +"")

def initialize(input, output = +"")
  @input = input
  @output = output
  @staged_output = []
end

def keep(pattern)

def keep(pattern)
  if match = consume(pattern)
    string = block_given? ? (yield match) : match.to_s
    @output << @staged_output.shift until @staged_output.empty?
    @output << string
    string
  end
end

def stage_output(pattern)

def stage_output(pattern)
  if match = consume(pattern)
    string = block_given? ? (yield match) : match.to_s
    @staged_output << string
    string
  end
end