Class: Content::Pipeline
- Inherits:
-
Object
- Object
- Content::Pipeline
- Defined in:
- lib/content/pipeline.rb,
lib/content/pipeline/filters.rb,
lib/content/pipeline/version.rb
Defined Under Namespace
Modules: Filters, Jekyll Classes: Filter
Constant Summary collapse
- VERSION =
"2.0.2"
Instance Attribute Summary collapse
-
#filters ⇒ Object
readonly
Returns the value of attribute filters.
-
#opts ⇒ Object
readonly
Returns the value of attribute opts.
Instance Method Summary collapse
- #filter(out, opts = {}) ⇒ Object
-
#initialize(filters = nil, opts = nil) ⇒ Pipeline
constructor
A new instance of Pipeline.
Constructor Details
#initialize(filters = nil, opts = nil) ⇒ Pipeline
Returns a new instance of Pipeline.
9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/content/pipeline.rb', line 9 def initialize(filters = nil, opts = nil) if filters.is_a?(Hash) && opts.nil? opts = filters filters = nil end opts = {} if opts.nil? filters = Filters::DEFAULT_FILTERS if filters.nil? @opts, @filters = opts.freeze, [ filters ].flatten.freeze end |
Instance Attribute Details
#filters ⇒ Object (readonly)
Returns the value of attribute filters.
7 8 9 |
# File 'lib/content/pipeline.rb', line 7 def filters @filters end |
#opts ⇒ Object (readonly)
Returns the value of attribute opts.
7 8 9 |
# File 'lib/content/pipeline.rb', line 7 def opts @opts end |
Instance Method Details
#filter(out, opts = {}) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/content/pipeline.rb', line 21 def filter(out, opts = {}) return out if out.nil? || out.empty? || @filters.empty? opts = @opts.deep_merge(opts) @filters.each_with_index do |f, i| fopts = opts.values_at(*to_opt(f)).delete_if(&:nil?). \ reduce({}, :merge) out = f.new(out, fopts).run(@filters[i + 1]) end out end |