Sha256: b9bbb9a79d3dd881931aeca26ef3b99bded2021c095b45ee47e1c0a695343a6b

Contents?: true

Size: 342 Bytes

Versions: 4

Compression:

Stored size: 342 Bytes

Contents

require_relative '../wrap'
require_relative 'layer'

module LovelyRufus
  module Layers
    class OneLetterGluer < Layer
      def call(wrap)
        pattern = /(?<=\p{space})(&|\p{letter})\p{space}/
        text    = wrap.text.gsub(pattern, "\\1\\2#{NBSP}")
        next_layer.call(Wrap[text, width: wrap.width])
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
lovely_rufus-1.0.0 lib/lovely_rufus/layers/one_letter_gluer.rb
lovely_rufus-0.3.2 lib/lovely_rufus/layers/one_letter_gluer.rb
lovely_rufus-0.3.1 lib/lovely_rufus/layers/one_letter_gluer.rb
lovely_rufus-0.3.0 lib/lovely_rufus/layers/one_letter_gluer.rb