truncate

truncate string at given length


Parameters

truncate string :string :literal
         cutoff :integer

Attributes

with:stringuse given filler
preservepreserve word boundaries

Returns

  • :string
  • or  :nothing

Examples

copy
str: "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse erat quam" truncate str 30 ; => "Lorem ipsum dolor sit amet, con..." truncate.preserve str 30 ; => "Lorem ipsum dolor sit amet,..." truncate.with:"---" str 30 ; => "Lorem ipsum dolor sit amet, con---" truncate.preserve.with:"---" str 30 ; => "Lorem ipsum dolor sit amet,---"

Related