Sha256: 655f000c1c0c3889d00a027ef6b66124dbc41cdc575d0d9b6e63c7630b3901a2
Contents?: true
Size: 534 Bytes
Versions: 10
Compression:
Stored size: 534 Bytes
Contents
# frozen_string_literal: true module Temple module Filters # Erase expressions with a certain type # # @api public class Eraser < Filter # [] is the empty type => keep all define_options :erase, keep: [[]] def compile(exp) exp.first == :multi || (do?(:keep, exp) && !do?(:erase, exp)) ? super(exp) : [:multi] end protected def do?(list, exp) options[list].to_a.map {|type| [*type] }.any? {|type| exp[0,type.size] == type } end end end end
Version data entries
10 entries across 9 versions & 3 rubygems