module Cabochon::StringUtils

Direct including types

Defined in:

lib/string_utils.cr

Instance Method Summary

Instance Method Detail

def capitalize?(str : String) : Bool #

Returns true if first character capitalized and the rest lowercased and there is at least one cased character, false otherwise.

str: The checked string


[View source]
def digit?(str : String) : Bool #

Returns true if all characters in the string are digits and there is at least one character, false otherwise.

digit?("") # => false
digit?("abc")   # => false
digit?("123")   # => true
digit?("12.34") # => false
digit?("1.5e5") # => false
digit?("-123")  # => false

str: The checked string.


[View source]
def downcase?(str : String) : Bool #

Return true if all cased characters in the string are lowercase and there is at least one cased character, false otherwise.

downcase?("") # => false
downcase?("Abc") # => false
downcase?("abc") # => true

str: The checked string.


[View source]
def downcase?(ch : Char) : Bool #

[View source]
def pad(string : String = "", length : Int = 0, chars : String = " ") : String #

Pads string on the left and right sides if it's shorter than length. Padding characters are truncated if they can't be evenly divided by length.

 pad("test", 8, "-=") # => "-=test-="

string: The string to pad. length: The padding length. chars: The string used as padding.


[View source]