lib/buhos/helpers.rb
# Truncate a text to given length and add truncate_string at the end
Truncate a text to given length and add truncate_string at the end
Truncate a text to given length and add truncate_string at the end
def truncate(text, length = 30, truncate_string = "...")
      if text
        l = length - truncate_string.chars.length
        chars = text.chars
        (chars.length > length ) ?
             (chars[0...l] + truncate_string.chars).join('').to_s :
             text
      end
    end
def truncate ( text , length = 30 , truncate_string = "..." ) if text l = length - truncate_string . chars . length chars = text . chars ( chars . length > length ) ? ( chars [ 0 ... l ] + truncate_string . chars ) . join ( '' ) . to_s : text end end
Truncate a text to given length and add truncate_string at the end
Truncate a text to given length and add truncate_string at the end
#$log.info(chars[0..10])
text
length
truncate_string