module Cythara

Overview

A small collection of String helpers

Defined in:

cythara/ansi.cr
cythara/version.cr
cythara/wrap.cr

Class Method Summary

Class Method Detail

def self.contains_ansi?(string) : Bool #

Returns true if string contains ANSI escape codes.


[View source]
def self.linewrap(string : String, width : Int32, strip_leading_space = true) : Array(String) #

Returns a line-wrapped representation of string.

Examples:

Cythara.linewrap("The quick brown fox", 6)        => ["The qu", "ick br", "own fo", "x"]
Cythara.linewrap("The quick brown fox", 15)       => ["The quick brown", "fox"]
Cythara.linewrap("The quick brown fox", 15, false) => ["The quick brown", " fox"]

[View source]
def self.strip_ansi(string) : String #

Returns string with all ANSI escape codes removed.


[View source]
def self.wordwrap(string : String, width : Int32, separators = [' ', '\n'], breakers = ['-']) : Array(String) #

Returns a word-wrapped representation of string.

Example:

Cythara.wordwrap("The quick brown fox", 11) => ["The quick", "brown fox"]

[View source]