Sha256: 371352506a6900f99c7e4e511c77e9bc96a0517ea9a14fb82ebc0a75ad99cbeb

Contents?: true

Size: 303 Bytes

Versions: 2

Compression:

Stored size: 303 Bytes

Contents

require_relative 'layer'
require_relative 'wrap'

module LovelyRufus
  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

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
lovely_rufus-0.2.1 lib/lovely_rufus/one_letter_gluer.rb
lovely_rufus-0.2.0 lib/lovely_rufus/one_letter_gluer.rb