module Fontist::Import::TextHelper
Public Class Methods
cleanup(text)
click to toggle source
# File lib/fontist/import/text_helper.rb, line 5 def cleanup(text) return unless text text.gsub("\r\n", "\n") .gsub("\r", "\n") .strip .lines .map(&:rstrip) .drop_while(&:empty?) .join("\n") end
longest_common_prefix(strs)
click to toggle source
# File lib/fontist/import/text_helper.rb, line 17 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.size < 2 prefix end