Sha256: 9ba9b1ba87054ed8751833dd993a48874a1ac6ec5e3d7f0e66dbcc73bc2e7444
Contents?: true
Size: 504 Bytes
Versions: 106
Compression:
Stored size: 504 Bytes
Contents
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
106 entries across 92 versions & 7 rubygems