Top Level Namespace

Defined Under Namespace

Modules: Cutword

Instance Method Summary collapse

Instance Method Details

#Cutword(max_length, text) ⇒ Object

lib/cutword.rb



3
4
5
6
7
8
9
10
# File 'lib/cutword.rb', line 3

def Cutword(max_length, text)
  if text.length > max_length
    truncated_text = text[0...max_length].strip
    truncated_text + (truncated_text.length < text.length ? '...' : '')
  else
    text
  end
end