Skip to content

Instantly share code, notes, and snippets.

@dimiro1
Created May 19, 2009 18:40
Show Gist options
  • Save dimiro1/114308 to your computer and use it in GitHub Desktop.
Save dimiro1/114308 to your computer and use it in GitHub Desktop.
def cut_string(text, length, ending)
text[0...length].strip + ending
end
# forma de uso
texto = "meu texto é muito comprido, por isso eu preciso de um metodo que minimize ele"
cut_string(texto, 10, "...") # "meu texto ..."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment