Module: ROF::Filters

Defined in:
lib/rof/filters.rb,
lib/rof/filters/work.rb,
lib/rof/filters/bendo.rb,
lib/rof/filters/label.rb,
lib/rof/filters/date_stamp.rb,
lib/rof/filters/file_to_url.rb,
lib/rof/filters/access_to_relsext.rb

Overview

A container class for all ROF filters. What is an ROF filter? @see ROF::Filters.for

Defined Under Namespace

Classes: AccessToRelsext, Bendo, DateStamp, FileToUrl, Label, UnknownFilterError, Work

Constant Summary collapse

AVAILABLE_FILTERS =
{
  "bendo" => ROF::Filters::Bendo,
  "datestamp" => ROF::Filters::DateStamp,
  "file-to-url" => ROF::Filters::FileToUrl,
  "label" => ROF::Filters::Label,
  "work" => ROF::Filters::Work,
  "access-to-relsext" => ROF::Filters::AccessToRelsext
}

Class Method Summary collapse

Class Method Details

.for(filter_name, options = {}) ⇒ ROF::Filter

Parameters:

  • filter_name (String)
    • the named filter you want to instantiate

  • options (Hash) (defaults to: {})
    • a hash (with symbol keys) that is used for configuring the instantiating of the filter

Returns:

Raises:

  • ROF::Filters::UnknownFilterError if the given filter name is not registered

See Also:

  • /spec/support/an_rof_filter./spec/support/an_rof_filter.rb
  • ROF::Filter


30
31
32
33
34
35
36
37
# File 'lib/rof/filters.rb', line 30

def self.for(filter_name, options = {})
  begin
    filter = AVAILABLE_FILTERS.fetch(filter_name)
  rescue KeyError
    raise UnknownFilterError.new(filter_name, AVAILABLE_FILTERS.keys)
  end
  filter.new(options)
end