Module: Fontist::Import::TextHelper
- Defined in:
- lib/fontist/import/text_helper.rb
Class Method Summary collapse
Class Method Details
.cleanup(text) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 |
# 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) ⇒ Object
17 18 19 20 21 22 23 24 25 26 |
# 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 |