Sha256: 1473365318721b464d70067c612318162a377336a48abac07766cf84a44eb348

Contents?: true

Size: 425 Bytes

Versions: 10

Compression:

Stored size: 425 Bytes

Contents

module Wovnrb
  class LinkReplacer < ReplacerBase
    def initialize(pattern, headers)
      @pattern = pattern
      @headers = headers
    end

    def replace(dom, lang)
      dom.xpath('//a').each do |node|
        next if wovn_ignore?(node)

        href = node.get_attribute('href')
        new_href = lang.add_lang_code(href, @pattern, @headers)
        node.set_attribute('href', new_href)
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
wovnrb-0.2.07.1 lib/wovnrb/html_replacers/link_replacer.rb
wovnrb-0.2.10 lib/wovnrb/html_replacers/link_replacer.rb
wovnrb-0.2.09 lib/wovnrb/html_replacers/link_replacer.rb
wovnrb-0.2.08 lib/wovnrb/html_replacers/link_replacer.rb
wovnrb-0.2.07 lib/wovnrb/html_replacers/link_replacer.rb
wovnrb-0.2.06 lib/wovnrb/html_replacers/link_replacer.rb
wovnrb-0.2.05 lib/wovnrb/html_replacers/link_replacer.rb
wovnrb-0.2.04 lib/wovnrb/html_replacers/link_replacer.rb
wovnrb-0.2.03 lib/wovnrb/html_replacers/link_replacer.rb
wovnrb-0.2.02 lib/wovnrb/html_replacers/link_replacer.rb