Class: String

Inherits:
Object
  • Object
show all
Defined in:
lib/plugins/stdout.rb

Instance Method Summary collapse

Instance Method Details

#truncate_column(col) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/plugins/stdout.rb', line 19

def truncate_column(col)
  count = 0
  str = String.new
  ret = []
  self.split(//u).each {|c|
    count += (c.bytesize == 1 ? 1 : 2)
    if count > col then
        ret.push(str)
        str = String.new
        count = 0
    end
    str += c
  }
  ret.push(str) unless str.empty?
  ret
end