Module: TDL::Util
- Defined in:
- lib/tdl/util.rb
Class Method Summary collapse
Class Method Details
.compress_data(data) ⇒ Object
17 18 19 20 21 22 23 |
# File 'lib/tdl/util.rb', line 17 def self.compress_data(data) if data.respond_to?(:split) "#{TDL::Util.compress_text(data)}" else "#{data}" end end |
.compress_text(text) ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 |
# File 'lib/tdl/util.rb', line 3 def self.compress_text(text) # DEBT compress text should not add quotes top_line, *remaing_content = text.split("\n") lines_remaining = remaing_content.size if lines_remaining > 1 "\"#{top_line} .. ( #{lines_remaining} more lines )\"" elsif lines_remaining == 1 "\"#{top_line} .. ( 1 more line )\"" else "\"#{top_line}\"" end end |