Class: Media::Filter::Chain

Inherits:
Object
  • Object
show all
Defined in:
lib/media/filter/chain.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args = {}, &block) ⇒ Chain

Returns a new instance of Chain.


6
7
8
9
10
# File 'lib/media/filter/chain.rb', line 6

def initialize(args={}, &block)
  @filters = args.fetch(:filters, [])
  
  block.arity < 1 ? instance_eval(&block) : block.call(self) if block_given?
end

Instance Attribute Details

#filtersObject (readonly)

Returns the value of attribute filters.


4
5
6
# File 'lib/media/filter/chain.rb', line 4

def filters
  @filters
end

Instance Method Details

#add_filter(name, &block) ⇒ Object Also known as: filter


16
17
18
# File 'lib/media/filter/chain.rb', line 16

def add_filter(name, &block)
  @filters << Filter.new(name: name, &block)
end

#to_sObject


12
13
14
# File 'lib/media/filter/chain.rb', line 12

def to_s
  filters.join(', ')
end