Class: AutoHtml::Image

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

Overview

Image filter

Instance Method Summary collapse

Constructor Details

#initialize(proxy: nil, alt: nil) ⇒ Image

Returns a new instance of Image.



6
7
8
9
# File 'lib/auto_html/image.rb', line 6

def initialize(proxy: nil, alt: nil)
  @proxy = proxy || ''
  @alt = alt
end

Instance Method Details

#call(text) ⇒ Object



11
12
13
14
15
# File 'lib/auto_html/image.rb', line 11

def call(text)
  text.gsub(image_pattern) do |match|
    TagHelper.tag(:img, src: @proxy + match, alt: @alt)
  end
end