Sha256: bb5adb20ad4f389092551beaaf5459fc2b169420da0f6e7137da334b2bed1d9c
Contents?: true
Size: 620 Bytes
Versions: 2
Compression:
Stored size: 620 Bytes
Contents
module Zemanta class Enhancer def initialize(text, opts = {}) @text = text @opts = opts end def enhance enhance! @text end private def enhance! words_to_anchor(@opts).each do |dictionary| link = "<a href=#{dictionary[:link]}>#{dictionary[:word]}</a>" @text.gsub!(dictionary[:word], link) end end def words_to_anchor(opts) suggest_markup(opts).links.map do |link| { word: link.anchor, link: link.target.first.url } end end def suggest_markup(opts = {}) Markup.fetch(@text, opts) end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
zemanta_client-0.0.4 | lib/zemanta/enhancer.rb |
zemanta_client-0.0.3 | lib/zemanta/enhancer.rb |