Class: String

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

Instance Method Summary collapse

Instance Method Details

#truncate_column(col) ⇒ Object



71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# File 'lib/plugins/stdout.rb', line 71

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