class Spina::TailwindPurger::Conveyor

Attributes

output[R]
staged_output[R]

Public Class Methods

new(input, output = +"") click to toggle source
# File lib/spina/tailwind_purger.rb, line 107
def initialize(input, output = +"")
  @input = input
  @output = output
  @staged_output = []
end

Public Instance Methods

conditionally_keep(pattern) { |match) ? match : (break "")| ... } click to toggle source
# File lib/spina/tailwind_purger.rb, line 137
def conditionally_keep(pattern)
  keep(pattern) do |match|
    (yield match) ? match.to_s : (break "")
  end
end
consume(pattern) click to toggle source
# File lib/spina/tailwind_purger.rb, line 113
def consume(pattern)
  match = pattern.match(@input)
  @input = match.post_match if match
  match
end
Also aliased as: discard
discard(pattern)
Alias for: consume
done?() click to toggle source
# File lib/spina/tailwind_purger.rb, line 143
def done?
  @input.empty?
end
keep(pattern) { |match) : match| ... } click to toggle source
# File lib/spina/tailwind_purger.rb, line 128
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
stage_output(pattern) { |match) : match| ... } click to toggle source
# File lib/spina/tailwind_purger.rb, line 120
def stage_output(pattern)
  if match = consume(pattern)
    string = block_given? ? (yield match) : match.to_s
    @staged_output << string
    string
  end
end