Class: Media::Filter::Chain
- Inherits:
-
Object
- Object
- Media::Filter::Chain
- Defined in:
- lib/media/filter/chain.rb
Instance Attribute Summary collapse
-
#filters ⇒ Object
readonly
Returns the value of attribute filters.
Instance Method Summary collapse
- #add_filter(name, &block) ⇒ Object (also: #filter)
-
#initialize(args = {}, &block) ⇒ Chain
constructor
A new instance of Chain.
- #to_s ⇒ Object
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
#filters ⇒ Object (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_s ⇒ Object
12 13 14 |
# File 'lib/media/filter/chain.rb', line 12 def to_s filters.join(', ') end |