Class: Nanoc2::BinaryFilter
- Defined in:
- lib/nanoc2/base/binary_filter.rb
Overview
Nanoc2::BinaryFilter is responsible for filtering binary assets. It is the (abstract) superclass for all binary filters. Subclasses should override the run
method.
Direct Known Subclasses
Constant Summary
Constants inherited from Plugin
Instance Method Summary collapse
-
#initialize(asset_rep, asset, site, other_assigns = {}) ⇒ BinaryFilter
constructor
Creates a new binary filter for the given asset and site.
-
#run(file) ⇒ Object
Runs the filter.
Methods inherited from Plugin
identifier, identifiers, named, register
Constructor Details
#initialize(asset_rep, asset, site, other_assigns = {}) ⇒ BinaryFilter
Creates a new binary filter for the given asset and site.
asset_rep
-
A proxy for the asset representation (Nanoc2::AssetRep) that should be compiled by this filter.
asset
-
A proxy for the asset (Nanoc2::Asset) for which
asset_rep
is the representation. site
-
The site (Nanoc2::Site) this filter belongs to.
other_assigns
-
A hash containing other variables that should be made available during filtering.
20 21 22 23 24 25 26 27 28 29 |
# File 'lib/nanoc2/base/binary_filter.rb', line 20 def initialize(asset_rep, asset, site, other_assigns={}) @asset_rep = asset_rep @asset = asset @pages = site.pages.map { |p| p.to_proxy } @assets = site.assets.map { |a| a.to_proxy } @layouts = site.layouts.map { |l| l.to_proxy } @config = site.config @site = site @other_assigns = other_assigns end |
Instance Method Details
#run(file) ⇒ Object
Runs the filter. This method returns a File instance pointing to a new file, containing the filtered content.
file
-
A File instance representing the incoming file that should be filtered. This file should not be modified.
Subclasses must implement this method.
38 39 40 |
# File 'lib/nanoc2/base/binary_filter.rb', line 38 def run(file) raise NotImplementedError.new("Nanoc2::BinaryFilter subclasses must implement #run") end |