Module: BibTeX::Filters

Defined in:
lib/bibtex/filters.rb,
lib/bibtex/filters/latex.rb,
lib/bibtex/filters/linebreaks.rb

Defined Under Namespace

Classes: LaTeX, LineBreaks

Constant Summary collapse

LOAD_PATH =
[File.expand_path('..', __FILE__), 'filters'].join('/').freeze

Class Method Summary collapse

Class Method Details

.resolve(filter) ⇒ Object


40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/bibtex/filters.rb', line 40

def self.resolve(filter)
  case
  when filter.respond_to?(:apply)
    filter
  when filter.respond_to?(:to_s)
    klass = Filter.subclasses.detect do |c|
      c.name == filter.to_s || c.name.split(/::/)[-1] =~ /^#{filter}$/i
    end
    klass && klass.instance
  else
    nil
  end
end

.resolve!(filter) ⇒ Object


36
37
38
# File 'lib/bibtex/filters.rb', line 36

def self.resolve!(filter)
  resolve(filter) || raise(ArgumentError, "Failed to load filter #{filter.inspect}")
end