It's a set of classes that provide often-used features (e.g. HTML escaping) or augment existing classes (such as Hash).
We'll take a look at some of the most useful.
Pluralises/singularises words, based on standard English rules or a lookup table for the more difficult ones.
require "lotus/utils/inflector"
Lotus::Utils::Inflector.pluralize("cow") #=> "cows"
Lotus::Utils::Inflector.pluralize("sheep") #=> "sheep"
Lotus::Utils::Inflector.pluralize("chicken") #=> "chickina" ??
Lotus::Utils::Inflector.singularize("chickens") #=> "chicken"
Adds methods that match common class names, to coerce other object types into these classes.
require "lotus/utils/kernel"
Lotus::Utils::Kernel.Array(true) # => [true]
Lotus::Utils::Kernel.Integer("1") # => 1
Lotus::Utils::Kernel.Time('2014-04-18') # => 2014-04-18 00:00:00 +0200
Provides methods for changing strings into parameters, constants, etc. Also adds pluralisation methods.
require "lotus/utils/string"
string = Lotus::Utils::String.new 'lotus_utils'
string.classify # => "LotusUtils"
string.titleize # => "Lotus Utils"
string.dasherize # => "lotus-utils"
string = Lotus::Utils::String.new 'chicken'
string.pluralize # => "chickina"
Create unix-style paths without worrying about separators. Also used for routes.
require "lotus/utils/path_prefix"
path_prefix = Lotus::Utils::PathPrefix.new('posts')
path_prefix.join('new').to_s # => "/posts/new"
path_prefix.join('/new').to_s # => "/posts/new"
Safely escape special characters in HTML, HTML attributes and URLs.
require "lotus/utils/escape"
Lotus::Utils::Escape.html('<script>alert(1);</script>')
#=> "<script>alert(1);</script>"
Lotus::Utils::Escape.html_attribute("some attribute")
#=> "some attribute"
Lotus::Utils::Escape.url("javascript:alert('xss')")
#=> ""
Hash-like object that allows you to access keys with strings or symbols, but stores internally with string keys.
require 'lotus/utils/attributes'
attributes = Lotus::Utils::Attributes.new(a: 1, b: { 2 => [3, 4] })
attributes.to_h # => { "a" => 1, "b" => { "2" => [3, 4] } }
Look up the API docs for more - it's the only place you can.