Sha256: 6f2ed4f174b35cbc54031ff7d191b4b906146ce6332a619d55d53161a0069c87

Contents?: true

Size: 399 Bytes

Versions: 1

Compression:

Stored size: 399 Bytes

Contents

# frozen_string_literal: true

require_relative '../wrap'
require_relative 'layer'

module LovelyRufus
  module Layers
    class OneLetterGluer < Layer
      # :reek:FeatureEnvy
      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

1 entries across 1 versions & 1 rubygems

Version Path
lovely_rufus-1.0.1 lib/lovely_rufus/layers/one_letter_gluer.rb