Class: String

Inherits:
Object
  • Object
show all
Defined in:
lib/libexcel/worksheet.rb

Instance Method Summary collapse

Instance Method Details

#ltruncate(to) ⇒ Object



118
119
120
# File 'lib/libexcel/worksheet.rb', line 118

def ltruncate(to)
  self[to, self.length]
end

#rtruncate(to) ⇒ Object



114
115
116
# File 'lib/libexcel/worksheet.rb', line 114

def rtruncate(to)
  self[0,to]
end

#truncateObject



104
105
106
107
108
109
110
111
112
# File 'lib/libexcel/worksheet.rb', line 104

def truncate
  return self if self.length <= 30

  half_length = self.length / 2
  lstring = self[0, half_length].rtruncate(half_length-(half_length-13))
  rstring = self[half_length, self.length].ltruncate(half_length-13)
  lstring << (self.length % 2 != 0 ? "..." : "....") << rstring
  lstring
end