Class: AutoHtml::Filter
- Inherits:
-
Object
- Object
- AutoHtml::Filter
- Defined in:
- lib/auto_html/filter.rb
Instance Method Summary collapse
- #apply(text, options = {}) ⇒ Object
-
#initialize(block) ⇒ Filter
constructor
A new instance of Filter.
- #with(options, &block) ⇒ Object
Constructor Details
#initialize(block) ⇒ Filter
Returns a new instance of Filter.
3 4 5 6 |
# File 'lib/auto_html/filter.rb', line 3 def initialize(block) @block = block @options = nil end |
Instance Method Details
#apply(text, options = {}) ⇒ Object
13 14 15 16 17 18 19 20 |
# File 'lib/auto_html/filter.rb', line 13 def apply(text, = {}) = @options && @options.merge() if @block.call(text.to_s.dup, ) else @block.call(text.to_s.dup) end end |
#with(options, &block) ⇒ Object
8 9 10 11 |
# File 'lib/auto_html/filter.rb', line 8 def with(, &block) @options = @block = block end |