Sha256: 26620fd6a3efdaf4bf5242e5b315e215ed89ea5f7627842f00c322d48ebb053a

Contents?: true

Size: 632 Bytes

Versions: 37

Compression:

Stored size: 632 Bytes

Contents

module Fontist
  module Import
    module TextHelper
      class << self
        def cleanup(text)
          return unless text

          text.gsub("\r\n", "\n")
            .gsub("\r", "\n")
            .strip
            .lines
            .map(&:rstrip)
            .drop_while(&:empty?)
            .join("\n")
        end

        def longest_common_prefix(strs)
          return if strs.empty?

          min, max = strs.minmax
          idx = min.size.times { |i| break i if min[i] != max[i] }
          prefix = min[0...idx].strip
          return if prefix.empty?

          prefix
        end
      end
    end
  end
end

Version data entries

37 entries across 37 versions & 1 rubygems

Version Path
fontist-1.13.2 lib/fontist/import/text_helper.rb
fontist-1.13.1 lib/fontist/import/text_helper.rb
fontist-1.13.0 lib/fontist/import/text_helper.rb
fontist-1.12.0 lib/fontist/import/text_helper.rb
fontist-1.11.7 lib/fontist/import/text_helper.rb
fontist-1.11.6 lib/fontist/import/text_helper.rb
fontist-1.11.5 lib/fontist/import/text_helper.rb
fontist-1.11.3 lib/fontist/import/text_helper.rb
fontist-1.11.2 lib/fontist/import/text_helper.rb
fontist-1.9.3 lib/fontist/import/text_helper.rb
fontist-1.9.2 lib/fontist/import/text_helper.rb
fontist-1.11.1 lib/fontist/import/text_helper.rb
fontist-1.10.1 lib/fontist/import/text_helper.rb
fontist-1.10.0 lib/fontist/import/text_helper.rb
fontist-1.9.1 lib/fontist/import/text_helper.rb
fontist-1.9.0 lib/fontist/import/text_helper.rb
fontist-1.8.13 lib/fontist/import/text_helper.rb
fontist-1.8.12 lib/fontist/import/text_helper.rb
fontist-1.8.11 lib/fontist/import/text_helper.rb
fontist-1.8.10 lib/fontist/import/text_helper.rb