module Cabochon::StringUtils
Direct including types
Defined in:
lib/string_utils.crInstance Method Summary
-
#capitalize?(str : String) : Bool
Returns true if first character capitalized and the rest lowercased and there is at least one cased character, false otherwise.
-
#digit?(str : String) : Bool
Returns true if all characters in the string are digits and there is at least one character, false otherwise.
-
#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?(ch : Char) : Bool
-
#pad(string : String = "", length : Int = 0, chars : String = " ") : String
Pads string on the left and right sides if it's shorter than length.
Instance Method Detail
Returns true if first character capitalized and the rest lowercased and there is at least one cased character, false otherwise.
str: The checked string
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.
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.
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.