Class: AutoHtml::Filter

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

Instance Method Summary collapse

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 = @options && @options.merge(options)
  if _options
    @block.call(text.to_s.dup, _options)
  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(options, &block)
  @options = options
  @block = block
end