class Bytewise::Filters::Filter

Constants

FILTERS

Public Class Methods

apply(name, ** args) click to toggle source

Applies a filter with a given name and passes the arguments to apply

# File lib/brace_markup/filters/filter.rb, line 37
def self.apply(name, ** args)
  name = name.to_sym if name.is_a? String

  if FILTERS.key? name
    klass = Object.const_get(FILTERS[name])
    filter = klass.new

    filter.apply(** args)
  else
    raise Exception.new("Filter '#{name}' not found.")
  end
end
map(name) click to toggle source

Maps a filter to a given name Usage:

class ToLowerFilter < ::Bytewise::Filters::Filter

map 'to_lower'

def apply(input:, **args)
   # Your code goes here.
end

end

# File lib/brace_markup/filters/filter.rb, line 29
def self.map(name)
  name = name.to_sym if name.is_a? String
  FILTERS[name] = self.name
end

Public Instance Methods

apply(input:, reference:, ** args) click to toggle source

This method is the actual filter method the return will be inserted to the current context.

@param input mixed @param reference ::Bytewise::Ast::Reference @param **args “Support for future params”

# File lib/brace_markup/filters/filter.rb, line 13
def apply(input:, reference:, ** args)
  input
end