Sha256: 658eea1e7f97576c92df9b9cb2f0a1f8ad26d838b47d307789355869209691be

Contents?: true

Size: 491 Bytes

Versions: 1

Compression:

Stored size: 491 Bytes

Contents

require 'uri'
require 'rinku'
require 'rexml/document'

module AutoHtml
  # Link filter
  class Link
    def initialize(target: nil, rel: nil)
      @target = target
      @rel = rel
    end

    def call(text)
      Rinku.auto_link(text, :all, target_attr)
    end

    private

    def attributes
      [target_attr, rel_attr].compact.join(' ')
    end

    def rel_attr
      %(rel="#{@rel}") if @rel
    end

    def target_attr
      %(target="#{@target}") if @target
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
auto_html-2.0.0 lib/auto_html/link.rb