Module: VER::Methods::AutoFill
- Defined in:
- lib/ver/methods/autofill.rb
Class Method Summary collapse
Class Method Details
.auto_fill_space(text) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/ver/methods/autofill.rb', line 6 def auto_fill_space(text) enabled = text.store(self, :enable) return text.insert(:insert, ' ') unless enabled from, to = 'insert linestart', 'insert lineend' line = text.get(from, to) if line.size < (text..auto_fill_width || 78) text.insert(:insert, ' ') else chunks = line.scan(/(.{1,78}[^\s])(?:\s|$)/) lines = chunks.join("\n") << ' ' text.replace(from, to, lines) end end |